github.com/v2fly/tools@v0.100.0/internal/lsp/source/api_json.go (about) 1 // Code generated by "github.com/v2fly/tools/gopls/doc/generate"; DO NOT EDIT. 2 3 package source 4 5 var GeneratedAPIJSON = &APIJSON{ 6 Options: map[string][]*OptionJSON{ 7 "User": { 8 { 9 Name: "buildFlags", 10 Type: "[]string", 11 Doc: "buildFlags is the set of flags passed on to the build system when invoked.\nIt is applied to queries like `go list`, which is used when discovering files.\nThe most common use is to set `-tags`.\n", 12 EnumKeys: EnumKeys{ 13 ValueType: "", 14 Keys: nil, 15 }, 16 EnumValues: nil, 17 Default: "[]", 18 Status: "", 19 Hierarchy: "build", 20 }, 21 { 22 Name: "env", 23 Type: "map[string]string", 24 Doc: "env adds environment variables to external commands run by `gopls`, most notably `go list`.\n", 25 EnumKeys: EnumKeys{ 26 ValueType: "", 27 Keys: nil, 28 }, 29 EnumValues: nil, 30 Default: "{}", 31 Status: "", 32 Hierarchy: "build", 33 }, 34 { 35 Name: "directoryFilters", 36 Type: "[]string", 37 Doc: "directoryFilters can be used to exclude unwanted directories from the\nworkspace. By default, all directories are included. Filters are an\noperator, `+` to include and `-` to exclude, followed by a path prefix\nrelative to the workspace folder. They are evaluated in order, and\nthe last filter that applies to a path controls whether it is included.\nThe path prefix can be empty, so an initial `-` excludes everything.\n\nExamples:\n\nExclude node_modules: `-node_modules`\n\nInclude only project_a: `-` (exclude everything), `+project_a`\n\nInclude only project_a, but not node_modules inside it: `-`, `+project_a`, `-project_a/node_modules`\n", 38 EnumKeys: EnumKeys{ 39 ValueType: "", 40 Keys: nil, 41 }, 42 EnumValues: nil, 43 Default: "[]", 44 Status: "", 45 Hierarchy: "build", 46 }, 47 { 48 Name: "memoryMode", 49 Type: "enum", 50 Doc: "memoryMode controls the tradeoff `gopls` makes between memory usage and\ncorrectness.\n\nValues other than `Normal` are untested and may break in surprising ways.\n", 51 EnumKeys: EnumKeys{ 52 ValueType: "", 53 Keys: nil, 54 }, 55 EnumValues: []EnumValue{ 56 { 57 Value: "\"DegradeClosed\"", 58 Doc: "`\"DegradeClosed\"`: In DegradeClosed mode, `gopls` will collect less information about\npackages without open files. As a result, features like Find\nReferences and Rename will miss results in such packages.\n", 59 }, 60 { 61 Value: "\"Normal\"", 62 Doc: "", 63 }, 64 }, 65 Default: "\"Normal\"", 66 Status: "experimental", 67 Hierarchy: "build", 68 }, 69 { 70 Name: "expandWorkspaceToModule", 71 Type: "bool", 72 Doc: "expandWorkspaceToModule instructs `gopls` to adjust the scope of the\nworkspace to find the best available module root. `gopls` first looks for\na go.mod file in any parent directory of the workspace folder, expanding\nthe scope to that directory if it exists. If no viable parent directory is\nfound, gopls will check if there is exactly one child directory containing\na go.mod file, narrowing the scope to that directory if it exists.\n", 73 EnumKeys: EnumKeys{ 74 ValueType: "", 75 Keys: nil, 76 }, 77 EnumValues: nil, 78 Default: "true", 79 Status: "experimental", 80 Hierarchy: "build", 81 }, 82 { 83 Name: "experimentalWorkspaceModule", 84 Type: "bool", 85 Doc: "experimentalWorkspaceModule opts a user into the experimental support\nfor multi-module workspaces.\n", 86 EnumKeys: EnumKeys{ 87 ValueType: "", 88 Keys: nil, 89 }, 90 EnumValues: nil, 91 Default: "false", 92 Status: "experimental", 93 Hierarchy: "build", 94 }, 95 { 96 Name: "experimentalPackageCacheKey", 97 Type: "bool", 98 Doc: "experimentalPackageCacheKey controls whether to use a coarser cache key\nfor package type information to increase cache hits. This setting removes\nthe user's environment, build flags, and working directory from the cache\nkey, which should be a safe change as all relevant inputs into the type\nchecking pass are already hashed into the key. This is temporarily guarded\nby an experiment because caching behavior is subtle and difficult to\ncomprehensively test.\n", 99 EnumKeys: EnumKeys{ 100 ValueType: "", 101 Keys: nil, 102 }, 103 EnumValues: nil, 104 Default: "true", 105 Status: "experimental", 106 Hierarchy: "build", 107 }, 108 { 109 Name: "allowModfileModifications", 110 Type: "bool", 111 Doc: "allowModfileModifications disables -mod=readonly, allowing imports from\nout-of-scope modules. This option will eventually be removed.\n", 112 EnumKeys: EnumKeys{ 113 ValueType: "", 114 Keys: nil, 115 }, 116 EnumValues: nil, 117 Default: "false", 118 Status: "experimental", 119 Hierarchy: "build", 120 }, 121 { 122 Name: "allowImplicitNetworkAccess", 123 Type: "bool", 124 Doc: "allowImplicitNetworkAccess disables GOPROXY=off, allowing implicit module\ndownloads rather than requiring user action. This option will eventually\nbe removed.\n", 125 EnumKeys: EnumKeys{ 126 ValueType: "", 127 Keys: nil, 128 }, 129 EnumValues: nil, 130 Default: "false", 131 Status: "experimental", 132 Hierarchy: "build", 133 }, 134 { 135 Name: "hoverKind", 136 Type: "enum", 137 Doc: "hoverKind controls the information that appears in the hover text.\nSingleLine and Structured are intended for use only by authors of editor plugins.\n", 138 EnumKeys: EnumKeys{ 139 ValueType: "", 140 Keys: nil, 141 }, 142 EnumValues: []EnumValue{ 143 { 144 Value: "\"FullDocumentation\"", 145 Doc: "", 146 }, 147 { 148 Value: "\"NoDocumentation\"", 149 Doc: "", 150 }, 151 { 152 Value: "\"SingleLine\"", 153 Doc: "", 154 }, 155 { 156 Value: "\"Structured\"", 157 Doc: "`\"Structured\"` is an experimental setting that returns a structured hover format.\nThis format separates the signature from the documentation, so that the client\ncan do more manipulation of these fields.\n\nThis should only be used by clients that support this behavior.\n", 158 }, 159 { 160 Value: "\"SynopsisDocumentation\"", 161 Doc: "", 162 }, 163 }, 164 Default: "\"FullDocumentation\"", 165 Status: "", 166 Hierarchy: "ui.documentation", 167 }, 168 { 169 Name: "linkTarget", 170 Type: "string", 171 Doc: "linkTarget controls where documentation links go.\nIt might be one of:\n\n* `\"godoc.org\"`\n* `\"pkg.go.dev\"`\n\nIf company chooses to use its own `godoc.org`, its address can be used as well.\n", 172 EnumKeys: EnumKeys{ 173 ValueType: "", 174 Keys: nil, 175 }, 176 EnumValues: nil, 177 Default: "\"pkg.go.dev\"", 178 Status: "", 179 Hierarchy: "ui.documentation", 180 }, 181 { 182 Name: "linksInHover", 183 Type: "bool", 184 Doc: "linksInHover toggles the presence of links to documentation in hover.\n", 185 EnumKeys: EnumKeys{ 186 ValueType: "", 187 Keys: nil, 188 }, 189 EnumValues: nil, 190 Default: "true", 191 Status: "", 192 Hierarchy: "ui.documentation", 193 }, 194 { 195 Name: "usePlaceholders", 196 Type: "bool", 197 Doc: "placeholders enables placeholders for function parameters or struct\nfields in completion responses.\n", 198 EnumKeys: EnumKeys{ 199 ValueType: "", 200 Keys: nil, 201 }, 202 EnumValues: nil, 203 Default: "false", 204 Status: "", 205 Hierarchy: "ui.completion", 206 }, 207 { 208 Name: "completionBudget", 209 Type: "time.Duration", 210 Doc: "completionBudget is the soft latency goal for completion requests. Most\nrequests finish in a couple milliseconds, but in some cases deep\ncompletions can take much longer. As we use up our budget we\ndynamically reduce the search scope to ensure we return timely\nresults. Zero means unlimited.\n", 211 EnumKeys: EnumKeys{ 212 ValueType: "", 213 Keys: nil, 214 }, 215 EnumValues: nil, 216 Default: "\"100ms\"", 217 Status: "debug", 218 Hierarchy: "ui.completion", 219 }, 220 { 221 Name: "matcher", 222 Type: "enum", 223 Doc: "matcher sets the algorithm that is used when calculating completion\ncandidates.\n", 224 EnumKeys: EnumKeys{ 225 ValueType: "", 226 Keys: nil, 227 }, 228 EnumValues: []EnumValue{ 229 { 230 Value: "\"CaseInsensitive\"", 231 Doc: "", 232 }, 233 { 234 Value: "\"CaseSensitive\"", 235 Doc: "", 236 }, 237 { 238 Value: "\"Fuzzy\"", 239 Doc: "", 240 }, 241 }, 242 Default: "\"Fuzzy\"", 243 Status: "advanced", 244 Hierarchy: "ui.completion", 245 }, 246 { 247 Name: "experimentalPostfixCompletions", 248 Type: "bool", 249 Doc: "experimentalPostfixCompletions enables artifical method snippets\nsuch as \"someSlice.sort!\".\n", 250 EnumKeys: EnumKeys{ 251 ValueType: "", 252 Keys: nil, 253 }, 254 EnumValues: nil, 255 Default: "false", 256 Status: "experimental", 257 Hierarchy: "ui.completion", 258 }, 259 { 260 Name: "importShortcut", 261 Type: "enum", 262 Doc: "importShortcut specifies whether import statements should link to\ndocumentation or go to definitions.\n", 263 EnumKeys: EnumKeys{ 264 ValueType: "", 265 Keys: nil, 266 }, 267 EnumValues: []EnumValue{ 268 { 269 Value: "\"Both\"", 270 Doc: "", 271 }, 272 { 273 Value: "\"Definition\"", 274 Doc: "", 275 }, 276 { 277 Value: "\"Link\"", 278 Doc: "", 279 }, 280 }, 281 Default: "\"Both\"", 282 Status: "", 283 Hierarchy: "ui.navigation", 284 }, 285 { 286 Name: "symbolMatcher", 287 Type: "enum", 288 Doc: "symbolMatcher sets the algorithm that is used when finding workspace symbols.\n", 289 EnumKeys: EnumKeys{ 290 ValueType: "", 291 Keys: nil, 292 }, 293 EnumValues: []EnumValue{ 294 { 295 Value: "\"CaseInsensitive\"", 296 Doc: "", 297 }, 298 { 299 Value: "\"CaseSensitive\"", 300 Doc: "", 301 }, 302 { 303 Value: "\"Fuzzy\"", 304 Doc: "", 305 }, 306 }, 307 Default: "\"Fuzzy\"", 308 Status: "advanced", 309 Hierarchy: "ui.navigation", 310 }, 311 { 312 Name: "symbolStyle", 313 Type: "enum", 314 Doc: "symbolStyle controls how symbols are qualified in symbol responses.\n\nExample Usage:\n\n```json5\n\"gopls\": {\n...\n \"symbolStyle\": \"dynamic\",\n...\n}\n```\n", 315 EnumKeys: EnumKeys{ 316 ValueType: "", 317 Keys: nil, 318 }, 319 EnumValues: []EnumValue{ 320 { 321 Value: "\"Dynamic\"", 322 Doc: "`\"Dynamic\"` uses whichever qualifier results in the highest scoring\nmatch for the given symbol query. Here a \"qualifier\" is any \"/\" or \".\"\ndelimited suffix of the fully qualified symbol. i.e. \"to/pkg.Foo.Field\" or\njust \"Foo.Field\".\n", 323 }, 324 { 325 Value: "\"Full\"", 326 Doc: "`\"Full\"` is fully qualified symbols, i.e.\n\"path/to/pkg.Foo.Field\".\n", 327 }, 328 { 329 Value: "\"Package\"", 330 Doc: "`\"Package\"` is package qualified symbols i.e.\n\"pkg.Foo.Field\".\n", 331 }, 332 }, 333 Default: "\"Dynamic\"", 334 Status: "advanced", 335 Hierarchy: "ui.navigation", 336 }, 337 { 338 Name: "analyses", 339 Type: "map[string]bool", 340 Doc: "analyses specify analyses that the user would like to enable or disable.\nA map of the names of analysis passes that should be enabled/disabled.\nA full list of analyzers that gopls uses can be found\n[here](https://github.com/golang/tools/blob/master/gopls/doc/analyzers.md).\n\nExample Usage:\n\n```json5\n...\n\"analyses\": {\n \"unreachable\": false, // Disable the unreachable analyzer.\n \"unusedparams\": true // Enable the unusedparams analyzer.\n}\n...\n```\n", 341 EnumKeys: EnumKeys{ 342 ValueType: "bool", 343 Keys: []EnumKey{ 344 { 345 Name: "\"asmdecl\"", 346 Doc: "report mismatches between assembly files and Go declarations", 347 Default: "true", 348 }, 349 { 350 Name: "\"assign\"", 351 Doc: "check for useless assignments\n\nThis checker reports assignments of the form x = x or a[i] = a[i].\nThese are almost always useless, and even when they aren't they are\nusually a mistake.", 352 Default: "true", 353 }, 354 { 355 Name: "\"atomic\"", 356 Doc: "check for common mistakes using the sync/atomic package\n\nThe atomic checker looks for assignment statements of the form:\n\n\tx = atomic.AddUint64(&x, 1)\n\nwhich are not atomic.", 357 Default: "true", 358 }, 359 { 360 Name: "\"atomicalign\"", 361 Doc: "check for non-64-bits-aligned arguments to sync/atomic functions", 362 Default: "true", 363 }, 364 { 365 Name: "\"bools\"", 366 Doc: "check for common mistakes involving boolean operators", 367 Default: "true", 368 }, 369 { 370 Name: "\"buildtag\"", 371 Doc: "check that +build tags are well-formed and correctly located", 372 Default: "true", 373 }, 374 { 375 Name: "\"cgocall\"", 376 Doc: "detect some violations of the cgo pointer passing rules\n\nCheck for invalid cgo pointer passing.\nThis looks for code that uses cgo to call C code passing values\nwhose types are almost always invalid according to the cgo pointer\nsharing rules.\nSpecifically, it warns about attempts to pass a Go chan, map, func,\nor slice to C, either directly, or via a pointer, array, or struct.", 377 Default: "true", 378 }, 379 { 380 Name: "\"composites\"", 381 Doc: "check for unkeyed composite literals\n\nThis analyzer reports a diagnostic for composite literals of struct\ntypes imported from another package that do not use the field-keyed\nsyntax. Such literals are fragile because the addition of a new field\n(even if unexported) to the struct will cause compilation to fail.\n\nAs an example,\n\n\terr = &net.DNSConfigError{err}\n\nshould be replaced by:\n\n\terr = &net.DNSConfigError{Err: err}\n", 382 Default: "true", 383 }, 384 { 385 Name: "\"copylocks\"", 386 Doc: "check for locks erroneously passed by value\n\nInadvertently copying a value containing a lock, such as sync.Mutex or\nsync.WaitGroup, may cause both copies to malfunction. Generally such\nvalues should be referred to through a pointer.", 387 Default: "true", 388 }, 389 { 390 Name: "\"deepequalerrors\"", 391 Doc: "check for calls of reflect.DeepEqual on error values\n\nThe deepequalerrors checker looks for calls of the form:\n\n reflect.DeepEqual(err1, err2)\n\nwhere err1 and err2 are errors. Using reflect.DeepEqual to compare\nerrors is discouraged.", 392 Default: "true", 393 }, 394 { 395 Name: "\"errorsas\"", 396 Doc: "report passing non-pointer or non-error values to errors.As\n\nThe errorsas analysis reports calls to errors.As where the type\nof the second argument is not a pointer to a type implementing error.", 397 Default: "true", 398 }, 399 { 400 Name: "\"fieldalignment\"", 401 Doc: "find structs that would use less memory if their fields were sorted\n\nThis analyzer find structs that can be rearranged to use less memory, and provides\na suggested edit with the optimal order.\n\nNote that there are two different diagnostics reported. One checks struct size,\nand the other reports \"pointer bytes\" used. Pointer bytes is how many bytes of the\nobject that the garbage collector has to potentially scan for pointers, for example:\n\n\tstruct { uint32; string }\n\nhave 16 pointer bytes because the garbage collector has to scan up through the string's\ninner pointer.\n\n\tstruct { string; *uint32 }\n\nhas 24 pointer bytes because it has to scan further through the *uint32.\n\n\tstruct { string; uint32 }\n\nhas 8 because it can stop immediately after the string pointer.\n", 402 Default: "false", 403 }, 404 { 405 Name: "\"httpresponse\"", 406 Doc: "check for mistakes using HTTP responses\n\nA common mistake when using the net/http package is to defer a function\ncall to close the http.Response Body before checking the error that\ndetermines whether the response is valid:\n\n\tresp, err := http.Head(url)\n\tdefer resp.Body.Close()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\t// (defer statement belongs here)\n\nThis checker helps uncover latent nil dereference bugs by reporting a\ndiagnostic for such mistakes.", 407 Default: "true", 408 }, 409 { 410 Name: "\"ifaceassert\"", 411 Doc: "detect impossible interface-to-interface type assertions\n\nThis checker flags type assertions v.(T) and corresponding type-switch cases\nin which the static type V of v is an interface that cannot possibly implement\nthe target interface T. This occurs when V and T contain methods with the same\nname but different signatures. Example:\n\n\tvar v interface {\n\t\tRead()\n\t}\n\t_ = v.(io.Reader)\n\nThe Read method in v has a different signature than the Read method in\nio.Reader, so this assertion cannot succeed.\n", 412 Default: "true", 413 }, 414 { 415 Name: "\"loopclosure\"", 416 Doc: "check references to loop variables from within nested functions\n\nThis analyzer checks for references to loop variables from within a\nfunction literal inside the loop body. It checks only instances where\nthe function literal is called in a defer or go statement that is the\nlast statement in the loop body, as otherwise we would need whole\nprogram analysis.\n\nFor example:\n\n\tfor i, v := range s {\n\t\tgo func() {\n\t\t\tprintln(i, v) // not what you might expect\n\t\t}()\n\t}\n\nSee: https://golang.org/doc/go_faq.html#closures_and_goroutines", 417 Default: "true", 418 }, 419 { 420 Name: "\"lostcancel\"", 421 Doc: "check cancel func returned by context.WithCancel is called\n\nThe cancellation function returned by context.WithCancel, WithTimeout,\nand WithDeadline must be called or the new context will remain live\nuntil its parent context is cancelled.\n(The background context is never cancelled.)", 422 Default: "true", 423 }, 424 { 425 Name: "\"nilfunc\"", 426 Doc: "check for useless comparisons between functions and nil\n\nA useless comparison is one like f == nil as opposed to f() == nil.", 427 Default: "true", 428 }, 429 { 430 Name: "\"nilness\"", 431 Doc: "check for redundant or impossible nil comparisons\n\nThe nilness checker inspects the control-flow graph of each function in\na package and reports nil pointer dereferences, degenerate nil\npointers, and panics with nil values. A degenerate comparison is of the form\nx==nil or x!=nil where x is statically known to be nil or non-nil. These are\noften a mistake, especially in control flow related to errors. Panics with nil\nvalues are checked because they are not detectable by\n\n\tif r := recover(); r != nil {\n\nThis check reports conditions such as:\n\n\tif f == nil { // impossible condition (f is a function)\n\t}\n\nand:\n\n\tp := &v\n\t...\n\tif p != nil { // tautological condition\n\t}\n\nand:\n\n\tif p == nil {\n\t\tprint(*p) // nil dereference\n\t}\n\nand:\n\n\tif p == nil {\n\t\tpanic(p)\n\t}\n", 432 Default: "false", 433 }, 434 { 435 Name: "\"printf\"", 436 Doc: "check consistency of Printf format strings and arguments\n\nThe check applies to known functions (for example, those in package fmt)\nas well as any detected wrappers of known functions.\n\nA function that wants to avail itself of printf checking but is not\nfound by this analyzer's heuristics (for example, due to use of\ndynamic calls) can insert a bogus call:\n\n\tif false {\n\t\t_ = fmt.Sprintf(format, args...) // enable printf checking\n\t}\n\nThe -funcs flag specifies a comma-separated list of names of additional\nknown formatting functions or methods. If the name contains a period,\nit must denote a specific function using one of the following forms:\n\n\tdir/pkg.Function\n\tdir/pkg.Type.Method\n\t(*dir/pkg.Type).Method\n\nOtherwise the name is interpreted as a case-insensitive unqualified\nidentifier such as \"errorf\". Either way, if a listed name ends in f, the\nfunction is assumed to be Printf-like, taking a format string before the\nargument list. Otherwise it is assumed to be Print-like, taking a list\nof arguments with no format string.\n", 437 Default: "true", 438 }, 439 { 440 Name: "\"shadow\"", 441 Doc: "check for possible unintended shadowing of variables\n\nThis analyzer check for shadowed variables.\nA shadowed variable is a variable declared in an inner scope\nwith the same name and type as a variable in an outer scope,\nand where the outer variable is mentioned after the inner one\nis declared.\n\n(This definition can be refined; the module generates too many\nfalse positives and is not yet enabled by default.)\n\nFor example:\n\n\tfunc BadRead(f *os.File, buf []byte) error {\n\t\tvar err error\n\t\tfor {\n\t\t\tn, err := f.Read(buf) // shadows the function variable 'err'\n\t\t\tif err != nil {\n\t\t\t\tbreak // causes return of wrong value\n\t\t\t}\n\t\t\tfoo(buf)\n\t\t}\n\t\treturn err\n\t}\n", 442 Default: "false", 443 }, 444 { 445 Name: "\"shift\"", 446 Doc: "check for shifts that equal or exceed the width of the integer", 447 Default: "true", 448 }, 449 { 450 Name: "\"simplifycompositelit\"", 451 Doc: "check for composite literal simplifications\n\nAn array, slice, or map composite literal of the form:\n\t[]T{T{}, T{}}\nwill be simplified to:\n\t[]T{{}, {}}\n\nThis is one of the simplifications that \"gofmt -s\" applies.", 452 Default: "true", 453 }, 454 { 455 Name: "\"simplifyrange\"", 456 Doc: "check for range statement simplifications\n\nA range of the form:\n\tfor x, _ = range v {...}\nwill be simplified to:\n\tfor x = range v {...}\n\nA range of the form:\n\tfor _ = range v {...}\nwill be simplified to:\n\tfor range v {...}\n\nThis is one of the simplifications that \"gofmt -s\" applies.", 457 Default: "true", 458 }, 459 { 460 Name: "\"simplifyslice\"", 461 Doc: "check for slice simplifications\n\nA slice expression of the form:\n\ts[a:len(s)]\nwill be simplified to:\n\ts[a:]\n\nThis is one of the simplifications that \"gofmt -s\" applies.", 462 Default: "true", 463 }, 464 { 465 Name: "\"sortslice\"", 466 Doc: "check the argument type of sort.Slice\n\nsort.Slice requires an argument of a slice type. Check that\nthe interface{} value passed to sort.Slice is actually a slice.", 467 Default: "true", 468 }, 469 { 470 Name: "\"stdmethods\"", 471 Doc: "check signature of methods of well-known interfaces\n\nSometimes a type may be intended to satisfy an interface but may fail to\ndo so because of a mistake in its method signature.\nFor example, the result of this WriteTo method should be (int64, error),\nnot error, to satisfy io.WriterTo:\n\n\ttype myWriterTo struct{...}\n func (myWriterTo) WriteTo(w io.Writer) error { ... }\n\nThis check ensures that each method whose name matches one of several\nwell-known interface methods from the standard library has the correct\nsignature for that interface.\n\nChecked method names include:\n\tFormat GobEncode GobDecode MarshalJSON MarshalXML\n\tPeek ReadByte ReadFrom ReadRune Scan Seek\n\tUnmarshalJSON UnreadByte UnreadRune WriteByte\n\tWriteTo\n", 472 Default: "true", 473 }, 474 { 475 Name: "\"stringintconv\"", 476 Doc: "check for string(int) conversions\n\nThis checker flags conversions of the form string(x) where x is an integer\n(but not byte or rune) type. Such conversions are discouraged because they\nreturn the UTF-8 representation of the Unicode code point x, and not a decimal\nstring representation of x as one might expect. Furthermore, if x denotes an\ninvalid code point, the conversion cannot be statically rejected.\n\nFor conversions that intend on using the code point, consider replacing them\nwith string(rune(x)). Otherwise, strconv.Itoa and its equivalents return the\nstring representation of the value in the desired base.\n", 477 Default: "true", 478 }, 479 { 480 Name: "\"structtag\"", 481 Doc: "check that struct field tags conform to reflect.StructTag.Get\n\nAlso report certain struct tags (json, xml) used with unexported fields.", 482 Default: "true", 483 }, 484 { 485 Name: "\"testinggoroutine\"", 486 Doc: "report calls to (*testing.T).Fatal from goroutines started by a test.\n\nFunctions that abruptly terminate a test, such as the Fatal, Fatalf, FailNow, and\nSkip{,f,Now} methods of *testing.T, must be called from the test goroutine itself.\nThis checker detects calls to these functions that occur within a goroutine\nstarted by the test. For example:\n\nfunc TestFoo(t *testing.T) {\n go func() {\n t.Fatal(\"oops\") // error: (*T).Fatal called from non-test goroutine\n }()\n}\n", 487 Default: "true", 488 }, 489 { 490 Name: "\"tests\"", 491 Doc: "check for common mistaken usages of tests and examples\n\nThe tests checker walks Test, Benchmark and Example functions checking\nmalformed names, wrong signatures and examples documenting non-existent\nidentifiers.\n\nPlease see the documentation for package testing in golang.org/pkg/testing\nfor the conventions that are enforced for Tests, Benchmarks, and Examples.", 492 Default: "true", 493 }, 494 { 495 Name: "\"unmarshal\"", 496 Doc: "report passing non-pointer or non-interface values to unmarshal\n\nThe unmarshal analysis reports calls to functions such as json.Unmarshal\nin which the argument type is not a pointer or an interface.", 497 Default: "true", 498 }, 499 { 500 Name: "\"unreachable\"", 501 Doc: "check for unreachable code\n\nThe unreachable analyzer finds statements that execution can never reach\nbecause they are preceded by an return statement, a call to panic, an\ninfinite loop, or similar constructs.", 502 Default: "true", 503 }, 504 { 505 Name: "\"unsafeptr\"", 506 Doc: "check for invalid conversions of uintptr to unsafe.Pointer\n\nThe unsafeptr analyzer reports likely incorrect uses of unsafe.Pointer\nto convert integers to pointers. A conversion from uintptr to\nunsafe.Pointer is invalid if it implies that there is a uintptr-typed\nword in memory that holds a pointer value, because that word will be\ninvisible to stack copying and to the garbage collector.", 507 Default: "true", 508 }, 509 { 510 Name: "\"unusedparams\"", 511 Doc: "check for unused parameters of functions\n\nThe unusedparams analyzer checks functions to see if there are\nany parameters that are not being used.\n\nTo reduce false positives it ignores:\n- methods\n- parameters that do not have a name or are underscored\n- functions in test files\n- functions with empty bodies or those with just a return stmt", 512 Default: "false", 513 }, 514 { 515 Name: "\"unusedresult\"", 516 Doc: "check for unused results of calls to some functions\n\nSome functions like fmt.Errorf return a result and have no side effects,\nso it is always a mistake to discard the result. This analyzer reports\ncalls to certain functions in which the result of the call is ignored.\n\nThe set of functions may be controlled using flags.", 517 Default: "true", 518 }, 519 { 520 Name: "\"unusedwrite\"", 521 Doc: "checks for unused writes\n\nThe analyzer reports instances of writes to struct fields and\narrays that are never read. Specifically, when a struct object\nor an array is copied, its elements are copied implicitly by\nthe compiler, and any element write to this copy does nothing\nwith the original object.\n\nFor example:\n\n\ttype T struct { x int }\n\tfunc f(input []T) {\n\t\tfor i, v := range input { // v is a copy\n\t\t\tv.x = i // unused write to field x\n\t\t}\n\t}\n\nAnother example is about non-pointer receiver:\n\n\ttype T struct { x int }\n\tfunc (t T) f() { // t is a copy\n\t\tt.x = i // unused write to field x\n\t}\n", 522 Default: "false", 523 }, 524 { 525 Name: "\"fillreturns\"", 526 Doc: "suggested fixes for \"wrong number of return values (want %d, got %d)\"\n\nThis checker provides suggested fixes for type errors of the\ntype \"wrong number of return values (want %d, got %d)\". For example:\n\tfunc m() (int, string, *bool, error) {\n\t\treturn\n\t}\nwill turn into\n\tfunc m() (int, string, *bool, error) {\n\t\treturn 0, \"\", nil, nil\n\t}\n\nThis functionality is similar to https://github.com/sqs/goreturns.\n", 527 Default: "true", 528 }, 529 { 530 Name: "\"nonewvars\"", 531 Doc: "suggested fixes for \"no new vars on left side of :=\"\n\nThis checker provides suggested fixes for type errors of the\ntype \"no new vars on left side of :=\". For example:\n\tz := 1\n\tz := 2\nwill turn into\n\tz := 1\n\tz = 2\n", 532 Default: "true", 533 }, 534 { 535 Name: "\"noresultvalues\"", 536 Doc: "suggested fixes for \"no result values expected\"\n\nThis checker provides suggested fixes for type errors of the\ntype \"no result values expected\". For example:\n\tfunc z() { return nil }\nwill turn into\n\tfunc z() { return }\n", 537 Default: "true", 538 }, 539 { 540 Name: "\"undeclaredname\"", 541 Doc: "suggested fixes for \"undeclared name: <>\"\n\nThis checker provides suggested fixes for type errors of the\ntype \"undeclared name: <>\". It will insert a new statement:\n\"<> := \".", 542 Default: "true", 543 }, 544 { 545 Name: "\"fillstruct\"", 546 Doc: "note incomplete struct initializations\n\nThis analyzer provides diagnostics for any struct literals that do not have\nany fields initialized. Because the suggested fix for this analysis is\nexpensive to compute, callers should compute it separately, using the\nSuggestedFix function below.\n", 547 Default: "true", 548 }, 549 }, 550 }, 551 EnumValues: nil, 552 Default: "{}", 553 Status: "", 554 Hierarchy: "ui.diagnostic", 555 }, 556 { 557 Name: "staticcheck", 558 Type: "bool", 559 Doc: "staticcheck enables additional analyses from staticcheck.io.\n", 560 EnumKeys: EnumKeys{ 561 ValueType: "", 562 Keys: nil, 563 }, 564 EnumValues: nil, 565 Default: "false", 566 Status: "experimental", 567 Hierarchy: "ui.diagnostic", 568 }, 569 { 570 Name: "annotations", 571 Type: "map[string]bool", 572 Doc: "annotations specifies the various kinds of optimization diagnostics\nthat should be reported by the gc_details command.\n", 573 EnumKeys: EnumKeys{ 574 ValueType: "bool", 575 Keys: []EnumKey{ 576 { 577 Name: "\"bounds\"", 578 Doc: "`\"bounds\"` controls bounds checking diagnostics.\n", 579 Default: "true", 580 }, 581 { 582 Name: "\"escape\"", 583 Doc: "`\"escape\"` controls diagnostics about escape choices.\n", 584 Default: "true", 585 }, 586 { 587 Name: "\"inline\"", 588 Doc: "`\"inline\"` controls diagnostics about inlining choices.\n", 589 Default: "true", 590 }, 591 { 592 Name: "\"nil\"", 593 Doc: "`\"nil\"` controls nil checks.\n", 594 Default: "true", 595 }, 596 }, 597 }, 598 EnumValues: nil, 599 Default: "{\"bounds\":true,\"escape\":true,\"inline\":true,\"nil\":true}", 600 Status: "experimental", 601 Hierarchy: "ui.diagnostic", 602 }, 603 { 604 Name: "experimentalDiagnosticsDelay", 605 Type: "time.Duration", 606 Doc: "experimentalDiagnosticsDelay controls the amount of time that gopls waits\nafter the most recent file modification before computing deep diagnostics.\nSimple diagnostics (parsing and type-checking) are always run immediately\non recently modified packages.\n\nThis option must be set to a valid duration string, for example `\"250ms\"`.\n", 607 EnumKeys: EnumKeys{ 608 ValueType: "", 609 Keys: nil, 610 }, 611 EnumValues: nil, 612 Default: "\"250ms\"", 613 Status: "experimental", 614 Hierarchy: "ui.diagnostic", 615 }, 616 { 617 Name: "codelenses", 618 Type: "map[string]bool", 619 Doc: "codelenses overrides the enabled/disabled state of code lenses. See the\n\"Code Lenses\" section of the\n[Settings page](https://github.com/golang/tools/blob/master/gopls/doc/settings.md)\nfor the list of supported lenses.\n\nExample Usage:\n\n```json5\n\"gopls\": {\n...\n \"codelens\": {\n \"generate\": false, // Don't show the `go generate` lens.\n \"gc_details\": true // Show a code lens toggling the display of gc's choices.\n }\n...\n}\n```\n", 620 EnumKeys: EnumKeys{ 621 ValueType: "bool", 622 Keys: []EnumKey{ 623 { 624 Name: "\"gc_details\"", 625 Doc: "Toggle the calculation of gc annotations.", 626 Default: "false", 627 }, 628 { 629 Name: "\"generate\"", 630 Doc: "Runs `go generate` for a given directory.", 631 Default: "true", 632 }, 633 { 634 Name: "\"regenerate_cgo\"", 635 Doc: "Regenerates cgo definitions.", 636 Default: "true", 637 }, 638 { 639 Name: "\"test\"", 640 Doc: "Runs `go test` for a specific set of test or benchmark functions.", 641 Default: "false", 642 }, 643 { 644 Name: "\"tidy\"", 645 Doc: "Runs `go mod tidy` for a module.", 646 Default: "true", 647 }, 648 { 649 Name: "\"upgrade_dependency\"", 650 Doc: "Upgrades a dependency in the go.mod file for a module.", 651 Default: "true", 652 }, 653 { 654 Name: "\"vendor\"", 655 Doc: "Runs `go mod vendor` for a module.", 656 Default: "true", 657 }, 658 }, 659 }, 660 EnumValues: nil, 661 Default: "{\"gc_details\":false,\"generate\":true,\"regenerate_cgo\":true,\"tidy\":true,\"upgrade_dependency\":true,\"vendor\":true}", 662 Status: "", 663 Hierarchy: "ui", 664 }, 665 { 666 Name: "semanticTokens", 667 Type: "bool", 668 Doc: "semanticTokens controls whether the LSP server will send\nsemantic tokens to the client.\n", 669 EnumKeys: EnumKeys{ 670 ValueType: "", 671 Keys: nil, 672 }, 673 EnumValues: nil, 674 Default: "false", 675 Status: "experimental", 676 Hierarchy: "ui", 677 }, 678 { 679 Name: "local", 680 Type: "string", 681 Doc: "local is the equivalent of the `goimports -local` flag, which puts\nimports beginning with this string after third-party packages. It should\nbe the prefix of the import path whose imports should be grouped\nseparately.\n", 682 EnumKeys: EnumKeys{ 683 ValueType: "", 684 Keys: nil, 685 }, 686 EnumValues: nil, 687 Default: "\"\"", 688 Status: "", 689 Hierarchy: "formatting", 690 }, 691 { 692 Name: "gofumpt", 693 Type: "bool", 694 Doc: "gofumpt indicates if we should run gofumpt formatting.\n", 695 EnumKeys: EnumKeys{ 696 ValueType: "", 697 Keys: nil, 698 }, 699 EnumValues: nil, 700 Default: "false", 701 Status: "", 702 Hierarchy: "formatting", 703 }, 704 { 705 Name: "verboseOutput", 706 Type: "bool", 707 Doc: "verboseOutput enables additional debug logging.\n", 708 EnumKeys: EnumKeys{ 709 ValueType: "", 710 Keys: nil, 711 }, 712 EnumValues: nil, 713 Default: "false", 714 Status: "debug", 715 Hierarchy: "", 716 }, 717 }, 718 }, 719 Commands: []*CommandJSON{ 720 { 721 Command: "gopls.add_dependency", 722 Title: "Add dependency", 723 Doc: "Adds a dependency to the go.mod file for a module.", 724 ArgDoc: "{\n\t// The go.mod file URI.\n\t\"URI\": string,\n\t// Additional args to pass to the go command.\n\t\"GoCmdArgs\": []string,\n\t// Whether to add a require directive.\n\t\"AddRequire\": bool,\n}", 725 }, 726 { 727 Command: "gopls.add_import", 728 Title: "", 729 Doc: "", 730 ArgDoc: "{\n\t\"ImportPath\": string,\n\t\"URI\": string,\n}", 731 }, 732 { 733 Command: "gopls.apply_fix", 734 Title: "Apply a fix", 735 Doc: "Applies a fix to a region of source code.", 736 ArgDoc: "{\n\t// The fix to apply.\n\t\"Fix\": string,\n\t// The file URI for the document to fix.\n\t\"URI\": string,\n\t// The document range to scan for fixes.\n\t\"Range\": {\n\t\t\"start\": {\n\t\t\t\"line\": uint32,\n\t\t\t\"character\": uint32,\n\t\t},\n\t\t\"end\": {\n\t\t\t\"line\": uint32,\n\t\t\t\"character\": uint32,\n\t\t},\n\t},\n}", 737 }, 738 { 739 Command: "gopls.check_upgrades", 740 Title: "Check for upgrades", 741 Doc: "Checks for module upgrades.", 742 ArgDoc: "{\n\t// The go.mod file URI.\n\t\"URI\": string,\n\t// The modules to check.\n\t\"Modules\": []string,\n}", 743 }, 744 { 745 Command: "gopls.gc_details", 746 Title: "Toggle gc_details", 747 Doc: "Toggle the calculation of gc annotations.", 748 ArgDoc: "string", 749 }, 750 { 751 Command: "gopls.generate", 752 Title: "Run go generate", 753 Doc: "Runs `go generate` for a given directory.", 754 ArgDoc: "{\n\t// URI for the directory to generate.\n\t\"Dir\": string,\n\t// Whether to generate recursively (go generate ./...)\n\t\"Recursive\": bool,\n}", 755 }, 756 { 757 Command: "gopls.generate_gopls_mod", 758 Title: "Generate gopls.mod", 759 Doc: "(Re)generate the gopls.mod file for a workspace.", 760 ArgDoc: "{\n\t// The file URI.\n\t\"URI\": string,\n}", 761 }, 762 { 763 Command: "gopls.go_get_package", 764 Title: "go get package", 765 Doc: "Runs `go get` to fetch a package.", 766 ArgDoc: "{\n\t// Any document URI within the relevant module.\n\t\"URI\": string,\n\t// The package to go get.\n\t\"Pkg\": string,\n\t\"AddRequire\": bool,\n}", 767 }, 768 { 769 Command: "gopls.list_known_packages", 770 Title: "", 771 Doc: "", 772 ArgDoc: "{\n\t// The file URI.\n\t\"URI\": string,\n}", 773 }, 774 { 775 Command: "gopls.regenerate_cgo", 776 Title: "Regenerate cgo", 777 Doc: "Regenerates cgo definitions.", 778 ArgDoc: "{\n\t// The file URI.\n\t\"URI\": string,\n}", 779 }, 780 { 781 Command: "gopls.remove_dependency", 782 Title: "Remove dependency", 783 Doc: "Removes a dependency from the go.mod file of a module.", 784 ArgDoc: "{\n\t// The go.mod file URI.\n\t\"URI\": string,\n\t// The module path to remove.\n\t\"ModulePath\": string,\n\t\"OnlyDiagnostic\": bool,\n}", 785 }, 786 { 787 Command: "gopls.run_tests", 788 Title: "Run test(s)", 789 Doc: "Runs `go test` for a specific set of test or benchmark functions.", 790 ArgDoc: "{\n\t// The test file containing the tests to run.\n\t\"URI\": string,\n\t// Specific test names to run, e.g. TestFoo.\n\t\"Tests\": []string,\n\t// Specific benchmarks to run, e.g. BenchmarkFoo.\n\t\"Benchmarks\": []string,\n}", 791 }, 792 { 793 Command: "gopls.start_debugging", 794 Title: "", 795 Doc: "", 796 ArgDoc: "{\n\t// Optional: the address (including port) for the debug server to listen on.\n\t// If not provided, the debug server will bind to \"localhost:0\", and the\n\t// full debug URL will be contained in the result.\n\t// \n\t// If there is more than one gopls instance along the serving path (i.e. you\n\t// are using a daemon), each gopls instance will attempt to start debugging.\n\t// If Addr specifies a port, only the daemon will be able to bind to that\n\t// port, and each intermediate gopls instance will fail to start debugging.\n\t// For this reason it is recommended not to specify a port (or equivalently,\n\t// to specify \":0\").\n\t// \n\t// If the server was already debugging this field has no effect, and the\n\t// result will contain the previously configured debug URL(s).\n\t\"Addr\": string,\n}", 797 }, 798 { 799 Command: "gopls.test", 800 Title: "Run test(s) (legacy)", 801 Doc: "Runs `go test` for a specific set of test or benchmark functions.", 802 ArgDoc: "string,\n[]string,\n[]string", 803 }, 804 { 805 Command: "gopls.tidy", 806 Title: "Run go mod tidy", 807 Doc: "Runs `go mod tidy` for a module.", 808 ArgDoc: "{\n\t// The file URIs.\n\t\"URIs\": []string,\n}", 809 }, 810 { 811 Command: "gopls.toggle_gc_details", 812 Title: "Toggle gc_details", 813 Doc: "Toggle the calculation of gc annotations.", 814 ArgDoc: "{\n\t// The file URI.\n\t\"URI\": string,\n}", 815 }, 816 { 817 Command: "gopls.update_go_sum", 818 Title: "Update go.sum", 819 Doc: "Updates the go.sum file for a module.", 820 ArgDoc: "{\n\t// The file URIs.\n\t\"URIs\": []string,\n}", 821 }, 822 { 823 Command: "gopls.upgrade_dependency", 824 Title: "Upgrade dependency", 825 Doc: "Upgrades a dependency in the go.mod file for a module.", 826 ArgDoc: "{\n\t// The go.mod file URI.\n\t\"URI\": string,\n\t// Additional args to pass to the go command.\n\t\"GoCmdArgs\": []string,\n\t// Whether to add a require directive.\n\t\"AddRequire\": bool,\n}", 827 }, 828 { 829 Command: "gopls.vendor", 830 Title: "Run go mod vendor", 831 Doc: "Runs `go mod vendor` for a module.", 832 ArgDoc: "{\n\t// The file URI.\n\t\"URI\": string,\n}", 833 }, 834 { 835 Command: "gopls.workspace_metadata", 836 Title: "", 837 Doc: "", 838 ArgDoc: "", 839 }, 840 }, 841 Lenses: []*LensJSON{ 842 { 843 Lens: "gc_details", 844 Title: "Toggle gc_details", 845 Doc: "Toggle the calculation of gc annotations.", 846 }, 847 { 848 Lens: "generate", 849 Title: "Run go generate", 850 Doc: "Runs `go generate` for a given directory.", 851 }, 852 { 853 Lens: "regenerate_cgo", 854 Title: "Regenerate cgo", 855 Doc: "Regenerates cgo definitions.", 856 }, 857 { 858 Lens: "test", 859 Title: "Run test(s) (legacy)", 860 Doc: "Runs `go test` for a specific set of test or benchmark functions.", 861 }, 862 { 863 Lens: "tidy", 864 Title: "Run go mod tidy", 865 Doc: "Runs `go mod tidy` for a module.", 866 }, 867 { 868 Lens: "upgrade_dependency", 869 Title: "Upgrade dependency", 870 Doc: "Upgrades a dependency in the go.mod file for a module.", 871 }, 872 { 873 Lens: "vendor", 874 Title: "Run go mod vendor", 875 Doc: "Runs `go mod vendor` for a module.", 876 }, 877 }, 878 Analyzers: []*AnalyzerJSON{ 879 { 880 Name: "asmdecl", 881 Doc: "report mismatches between assembly files and Go declarations", 882 Default: true, 883 }, 884 { 885 Name: "assign", 886 Doc: "check for useless assignments\n\nThis checker reports assignments of the form x = x or a[i] = a[i].\nThese are almost always useless, and even when they aren't they are\nusually a mistake.", 887 Default: true, 888 }, 889 { 890 Name: "atomic", 891 Doc: "check for common mistakes using the sync/atomic package\n\nThe atomic checker looks for assignment statements of the form:\n\n\tx = atomic.AddUint64(&x, 1)\n\nwhich are not atomic.", 892 Default: true, 893 }, 894 { 895 Name: "atomicalign", 896 Doc: "check for non-64-bits-aligned arguments to sync/atomic functions", 897 Default: true, 898 }, 899 { 900 Name: "bools", 901 Doc: "check for common mistakes involving boolean operators", 902 Default: true, 903 }, 904 { 905 Name: "buildtag", 906 Doc: "check that +build tags are well-formed and correctly located", 907 Default: true, 908 }, 909 { 910 Name: "cgocall", 911 Doc: "detect some violations of the cgo pointer passing rules\n\nCheck for invalid cgo pointer passing.\nThis looks for code that uses cgo to call C code passing values\nwhose types are almost always invalid according to the cgo pointer\nsharing rules.\nSpecifically, it warns about attempts to pass a Go chan, map, func,\nor slice to C, either directly, or via a pointer, array, or struct.", 912 Default: true, 913 }, 914 { 915 Name: "composites", 916 Doc: "check for unkeyed composite literals\n\nThis analyzer reports a diagnostic for composite literals of struct\ntypes imported from another package that do not use the field-keyed\nsyntax. Such literals are fragile because the addition of a new field\n(even if unexported) to the struct will cause compilation to fail.\n\nAs an example,\n\n\terr = &net.DNSConfigError{err}\n\nshould be replaced by:\n\n\terr = &net.DNSConfigError{Err: err}\n", 917 Default: true, 918 }, 919 { 920 Name: "copylocks", 921 Doc: "check for locks erroneously passed by value\n\nInadvertently copying a value containing a lock, such as sync.Mutex or\nsync.WaitGroup, may cause both copies to malfunction. Generally such\nvalues should be referred to through a pointer.", 922 Default: true, 923 }, 924 { 925 Name: "deepequalerrors", 926 Doc: "check for calls of reflect.DeepEqual on error values\n\nThe deepequalerrors checker looks for calls of the form:\n\n reflect.DeepEqual(err1, err2)\n\nwhere err1 and err2 are errors. Using reflect.DeepEqual to compare\nerrors is discouraged.", 927 Default: true, 928 }, 929 { 930 Name: "errorsas", 931 Doc: "report passing non-pointer or non-error values to errors.As\n\nThe errorsas analysis reports calls to errors.As where the type\nof the second argument is not a pointer to a type implementing error.", 932 Default: true, 933 }, 934 { 935 Name: "fieldalignment", 936 Doc: "find structs that would use less memory if their fields were sorted\n\nThis analyzer find structs that can be rearranged to use less memory, and provides\na suggested edit with the optimal order.\n\nNote that there are two different diagnostics reported. One checks struct size,\nand the other reports \"pointer bytes\" used. Pointer bytes is how many bytes of the\nobject that the garbage collector has to potentially scan for pointers, for example:\n\n\tstruct { uint32; string }\n\nhave 16 pointer bytes because the garbage collector has to scan up through the string's\ninner pointer.\n\n\tstruct { string; *uint32 }\n\nhas 24 pointer bytes because it has to scan further through the *uint32.\n\n\tstruct { string; uint32 }\n\nhas 8 because it can stop immediately after the string pointer.\n", 937 Default: false, 938 }, 939 { 940 Name: "httpresponse", 941 Doc: "check for mistakes using HTTP responses\n\nA common mistake when using the net/http package is to defer a function\ncall to close the http.Response Body before checking the error that\ndetermines whether the response is valid:\n\n\tresp, err := http.Head(url)\n\tdefer resp.Body.Close()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\t// (defer statement belongs here)\n\nThis checker helps uncover latent nil dereference bugs by reporting a\ndiagnostic for such mistakes.", 942 Default: true, 943 }, 944 { 945 Name: "ifaceassert", 946 Doc: "detect impossible interface-to-interface type assertions\n\nThis checker flags type assertions v.(T) and corresponding type-switch cases\nin which the static type V of v is an interface that cannot possibly implement\nthe target interface T. This occurs when V and T contain methods with the same\nname but different signatures. Example:\n\n\tvar v interface {\n\t\tRead()\n\t}\n\t_ = v.(io.Reader)\n\nThe Read method in v has a different signature than the Read method in\nio.Reader, so this assertion cannot succeed.\n", 947 Default: true, 948 }, 949 { 950 Name: "loopclosure", 951 Doc: "check references to loop variables from within nested functions\n\nThis analyzer checks for references to loop variables from within a\nfunction literal inside the loop body. It checks only instances where\nthe function literal is called in a defer or go statement that is the\nlast statement in the loop body, as otherwise we would need whole\nprogram analysis.\n\nFor example:\n\n\tfor i, v := range s {\n\t\tgo func() {\n\t\t\tprintln(i, v) // not what you might expect\n\t\t}()\n\t}\n\nSee: https://golang.org/doc/go_faq.html#closures_and_goroutines", 952 Default: true, 953 }, 954 { 955 Name: "lostcancel", 956 Doc: "check cancel func returned by context.WithCancel is called\n\nThe cancellation function returned by context.WithCancel, WithTimeout,\nand WithDeadline must be called or the new context will remain live\nuntil its parent context is cancelled.\n(The background context is never cancelled.)", 957 Default: true, 958 }, 959 { 960 Name: "nilfunc", 961 Doc: "check for useless comparisons between functions and nil\n\nA useless comparison is one like f == nil as opposed to f() == nil.", 962 Default: true, 963 }, 964 { 965 Name: "nilness", 966 Doc: "check for redundant or impossible nil comparisons\n\nThe nilness checker inspects the control-flow graph of each function in\na package and reports nil pointer dereferences, degenerate nil\npointers, and panics with nil values. A degenerate comparison is of the form\nx==nil or x!=nil where x is statically known to be nil or non-nil. These are\noften a mistake, especially in control flow related to errors. Panics with nil\nvalues are checked because they are not detectable by\n\n\tif r := recover(); r != nil {\n\nThis check reports conditions such as:\n\n\tif f == nil { // impossible condition (f is a function)\n\t}\n\nand:\n\n\tp := &v\n\t...\n\tif p != nil { // tautological condition\n\t}\n\nand:\n\n\tif p == nil {\n\t\tprint(*p) // nil dereference\n\t}\n\nand:\n\n\tif p == nil {\n\t\tpanic(p)\n\t}\n", 967 Default: false, 968 }, 969 { 970 Name: "printf", 971 Doc: "check consistency of Printf format strings and arguments\n\nThe check applies to known functions (for example, those in package fmt)\nas well as any detected wrappers of known functions.\n\nA function that wants to avail itself of printf checking but is not\nfound by this analyzer's heuristics (for example, due to use of\ndynamic calls) can insert a bogus call:\n\n\tif false {\n\t\t_ = fmt.Sprintf(format, args...) // enable printf checking\n\t}\n\nThe -funcs flag specifies a comma-separated list of names of additional\nknown formatting functions or methods. If the name contains a period,\nit must denote a specific function using one of the following forms:\n\n\tdir/pkg.Function\n\tdir/pkg.Type.Method\n\t(*dir/pkg.Type).Method\n\nOtherwise the name is interpreted as a case-insensitive unqualified\nidentifier such as \"errorf\". Either way, if a listed name ends in f, the\nfunction is assumed to be Printf-like, taking a format string before the\nargument list. Otherwise it is assumed to be Print-like, taking a list\nof arguments with no format string.\n", 972 Default: true, 973 }, 974 { 975 Name: "shadow", 976 Doc: "check for possible unintended shadowing of variables\n\nThis analyzer check for shadowed variables.\nA shadowed variable is a variable declared in an inner scope\nwith the same name and type as a variable in an outer scope,\nand where the outer variable is mentioned after the inner one\nis declared.\n\n(This definition can be refined; the module generates too many\nfalse positives and is not yet enabled by default.)\n\nFor example:\n\n\tfunc BadRead(f *os.File, buf []byte) error {\n\t\tvar err error\n\t\tfor {\n\t\t\tn, err := f.Read(buf) // shadows the function variable 'err'\n\t\t\tif err != nil {\n\t\t\t\tbreak // causes return of wrong value\n\t\t\t}\n\t\t\tfoo(buf)\n\t\t}\n\t\treturn err\n\t}\n", 977 Default: false, 978 }, 979 { 980 Name: "shift", 981 Doc: "check for shifts that equal or exceed the width of the integer", 982 Default: true, 983 }, 984 { 985 Name: "simplifycompositelit", 986 Doc: "check for composite literal simplifications\n\nAn array, slice, or map composite literal of the form:\n\t[]T{T{}, T{}}\nwill be simplified to:\n\t[]T{{}, {}}\n\nThis is one of the simplifications that \"gofmt -s\" applies.", 987 Default: true, 988 }, 989 { 990 Name: "simplifyrange", 991 Doc: "check for range statement simplifications\n\nA range of the form:\n\tfor x, _ = range v {...}\nwill be simplified to:\n\tfor x = range v {...}\n\nA range of the form:\n\tfor _ = range v {...}\nwill be simplified to:\n\tfor range v {...}\n\nThis is one of the simplifications that \"gofmt -s\" applies.", 992 Default: true, 993 }, 994 { 995 Name: "simplifyslice", 996 Doc: "check for slice simplifications\n\nA slice expression of the form:\n\ts[a:len(s)]\nwill be simplified to:\n\ts[a:]\n\nThis is one of the simplifications that \"gofmt -s\" applies.", 997 Default: true, 998 }, 999 { 1000 Name: "sortslice", 1001 Doc: "check the argument type of sort.Slice\n\nsort.Slice requires an argument of a slice type. Check that\nthe interface{} value passed to sort.Slice is actually a slice.", 1002 Default: true, 1003 }, 1004 { 1005 Name: "stdmethods", 1006 Doc: "check signature of methods of well-known interfaces\n\nSometimes a type may be intended to satisfy an interface but may fail to\ndo so because of a mistake in its method signature.\nFor example, the result of this WriteTo method should be (int64, error),\nnot error, to satisfy io.WriterTo:\n\n\ttype myWriterTo struct{...}\n func (myWriterTo) WriteTo(w io.Writer) error { ... }\n\nThis check ensures that each method whose name matches one of several\nwell-known interface methods from the standard library has the correct\nsignature for that interface.\n\nChecked method names include:\n\tFormat GobEncode GobDecode MarshalJSON MarshalXML\n\tPeek ReadByte ReadFrom ReadRune Scan Seek\n\tUnmarshalJSON UnreadByte UnreadRune WriteByte\n\tWriteTo\n", 1007 Default: true, 1008 }, 1009 { 1010 Name: "stringintconv", 1011 Doc: "check for string(int) conversions\n\nThis checker flags conversions of the form string(x) where x is an integer\n(but not byte or rune) type. Such conversions are discouraged because they\nreturn the UTF-8 representation of the Unicode code point x, and not a decimal\nstring representation of x as one might expect. Furthermore, if x denotes an\ninvalid code point, the conversion cannot be statically rejected.\n\nFor conversions that intend on using the code point, consider replacing them\nwith string(rune(x)). Otherwise, strconv.Itoa and its equivalents return the\nstring representation of the value in the desired base.\n", 1012 Default: true, 1013 }, 1014 { 1015 Name: "structtag", 1016 Doc: "check that struct field tags conform to reflect.StructTag.Get\n\nAlso report certain struct tags (json, xml) used with unexported fields.", 1017 Default: true, 1018 }, 1019 { 1020 Name: "testinggoroutine", 1021 Doc: "report calls to (*testing.T).Fatal from goroutines started by a test.\n\nFunctions that abruptly terminate a test, such as the Fatal, Fatalf, FailNow, and\nSkip{,f,Now} methods of *testing.T, must be called from the test goroutine itself.\nThis checker detects calls to these functions that occur within a goroutine\nstarted by the test. For example:\n\nfunc TestFoo(t *testing.T) {\n go func() {\n t.Fatal(\"oops\") // error: (*T).Fatal called from non-test goroutine\n }()\n}\n", 1022 Default: true, 1023 }, 1024 { 1025 Name: "tests", 1026 Doc: "check for common mistaken usages of tests and examples\n\nThe tests checker walks Test, Benchmark and Example functions checking\nmalformed names, wrong signatures and examples documenting non-existent\nidentifiers.\n\nPlease see the documentation for package testing in golang.org/pkg/testing\nfor the conventions that are enforced for Tests, Benchmarks, and Examples.", 1027 Default: true, 1028 }, 1029 { 1030 Name: "unmarshal", 1031 Doc: "report passing non-pointer or non-interface values to unmarshal\n\nThe unmarshal analysis reports calls to functions such as json.Unmarshal\nin which the argument type is not a pointer or an interface.", 1032 Default: true, 1033 }, 1034 { 1035 Name: "unreachable", 1036 Doc: "check for unreachable code\n\nThe unreachable analyzer finds statements that execution can never reach\nbecause they are preceded by an return statement, a call to panic, an\ninfinite loop, or similar constructs.", 1037 Default: true, 1038 }, 1039 { 1040 Name: "unsafeptr", 1041 Doc: "check for invalid conversions of uintptr to unsafe.Pointer\n\nThe unsafeptr analyzer reports likely incorrect uses of unsafe.Pointer\nto convert integers to pointers. A conversion from uintptr to\nunsafe.Pointer is invalid if it implies that there is a uintptr-typed\nword in memory that holds a pointer value, because that word will be\ninvisible to stack copying and to the garbage collector.", 1042 Default: true, 1043 }, 1044 { 1045 Name: "unusedparams", 1046 Doc: "check for unused parameters of functions\n\nThe unusedparams analyzer checks functions to see if there are\nany parameters that are not being used.\n\nTo reduce false positives it ignores:\n- methods\n- parameters that do not have a name or are underscored\n- functions in test files\n- functions with empty bodies or those with just a return stmt", 1047 Default: false, 1048 }, 1049 { 1050 Name: "unusedresult", 1051 Doc: "check for unused results of calls to some functions\n\nSome functions like fmt.Errorf return a result and have no side effects,\nso it is always a mistake to discard the result. This analyzer reports\ncalls to certain functions in which the result of the call is ignored.\n\nThe set of functions may be controlled using flags.", 1052 Default: true, 1053 }, 1054 { 1055 Name: "unusedwrite", 1056 Doc: "checks for unused writes\n\nThe analyzer reports instances of writes to struct fields and\narrays that are never read. Specifically, when a struct object\nor an array is copied, its elements are copied implicitly by\nthe compiler, and any element write to this copy does nothing\nwith the original object.\n\nFor example:\n\n\ttype T struct { x int }\n\tfunc f(input []T) {\n\t\tfor i, v := range input { // v is a copy\n\t\t\tv.x = i // unused write to field x\n\t\t}\n\t}\n\nAnother example is about non-pointer receiver:\n\n\ttype T struct { x int }\n\tfunc (t T) f() { // t is a copy\n\t\tt.x = i // unused write to field x\n\t}\n", 1057 Default: false, 1058 }, 1059 { 1060 Name: "fillreturns", 1061 Doc: "suggested fixes for \"wrong number of return values (want %d, got %d)\"\n\nThis checker provides suggested fixes for type errors of the\ntype \"wrong number of return values (want %d, got %d)\". For example:\n\tfunc m() (int, string, *bool, error) {\n\t\treturn\n\t}\nwill turn into\n\tfunc m() (int, string, *bool, error) {\n\t\treturn 0, \"\", nil, nil\n\t}\n\nThis functionality is similar to https://github.com/sqs/goreturns.\n", 1062 Default: true, 1063 }, 1064 { 1065 Name: "nonewvars", 1066 Doc: "suggested fixes for \"no new vars on left side of :=\"\n\nThis checker provides suggested fixes for type errors of the\ntype \"no new vars on left side of :=\". For example:\n\tz := 1\n\tz := 2\nwill turn into\n\tz := 1\n\tz = 2\n", 1067 Default: true, 1068 }, 1069 { 1070 Name: "noresultvalues", 1071 Doc: "suggested fixes for \"no result values expected\"\n\nThis checker provides suggested fixes for type errors of the\ntype \"no result values expected\". For example:\n\tfunc z() { return nil }\nwill turn into\n\tfunc z() { return }\n", 1072 Default: true, 1073 }, 1074 { 1075 Name: "undeclaredname", 1076 Doc: "suggested fixes for \"undeclared name: <>\"\n\nThis checker provides suggested fixes for type errors of the\ntype \"undeclared name: <>\". It will insert a new statement:\n\"<> := \".", 1077 Default: true, 1078 }, 1079 { 1080 Name: "fillstruct", 1081 Doc: "note incomplete struct initializations\n\nThis analyzer provides diagnostics for any struct literals that do not have\nany fields initialized. Because the suggested fix for this analysis is\nexpensive to compute, callers should compute it separately, using the\nSuggestedFix function below.\n", 1082 Default: true, 1083 }, 1084 }, 1085 }