github.com/jhump/golang-x-tools@v0.0.0-20220218190644-4958d6d39439/internal/lsp/source/api_json.go (about) 1 // Code generated by "github.com/jhump/golang-x-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 Default: "[]", 13 Hierarchy: "build", 14 }, 15 { 16 Name: "env", 17 Type: "map[string]string", 18 Doc: "env adds environment variables to external commands run by `gopls`, most notably `go list`.\n", 19 Default: "{}", 20 Hierarchy: "build", 21 }, 22 { 23 Name: "directoryFilters", 24 Type: "[]string", 25 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", 26 Default: "[\"-node_modules\"]", 27 Hierarchy: "build", 28 }, 29 { 30 Name: "templateExtensions", 31 Type: "[]string", 32 Doc: "templateExtensions gives the extensions of file names that are treateed\nas template files. (The extension\nis the part of the file name after the final dot.)\n", 33 Default: "[]", 34 Hierarchy: "build", 35 }, 36 { 37 Name: "memoryMode", 38 Type: "enum", 39 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", 40 EnumValues: []EnumValue{ 41 { 42 Value: "\"DegradeClosed\"", 43 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", 44 }, 45 {Value: "\"Normal\""}, 46 }, 47 Default: "\"Normal\"", 48 Status: "experimental", 49 Hierarchy: "build", 50 }, 51 { 52 Name: "expandWorkspaceToModule", 53 Type: "bool", 54 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", 55 Default: "true", 56 Status: "experimental", 57 Hierarchy: "build", 58 }, 59 { 60 Name: "experimentalWorkspaceModule", 61 Type: "bool", 62 Doc: "experimentalWorkspaceModule opts a user into the experimental support\nfor multi-module workspaces.\n", 63 Default: "false", 64 Status: "experimental", 65 Hierarchy: "build", 66 }, 67 { 68 Name: "experimentalPackageCacheKey", 69 Type: "bool", 70 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", 71 Default: "true", 72 Status: "experimental", 73 Hierarchy: "build", 74 }, 75 { 76 Name: "allowModfileModifications", 77 Type: "bool", 78 Doc: "allowModfileModifications disables -mod=readonly, allowing imports from\nout-of-scope modules. This option will eventually be removed.\n", 79 Default: "false", 80 Status: "experimental", 81 Hierarchy: "build", 82 }, 83 { 84 Name: "allowImplicitNetworkAccess", 85 Type: "bool", 86 Doc: "allowImplicitNetworkAccess disables GOPROXY=off, allowing implicit module\ndownloads rather than requiring user action. This option will eventually\nbe removed.\n", 87 Default: "false", 88 Status: "experimental", 89 Hierarchy: "build", 90 }, 91 { 92 Name: "experimentalUseInvalidMetadata", 93 Type: "bool", 94 Doc: "experimentalUseInvalidMetadata enables gopls to fall back on outdated\npackage metadata to provide editor features if the go command fails to\nload packages for some reason (like an invalid go.mod file). This will\neventually be the default behavior, and this setting will be removed.\n", 95 Default: "false", 96 Status: "experimental", 97 Hierarchy: "build", 98 }, 99 { 100 Name: "hoverKind", 101 Type: "enum", 102 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", 103 EnumValues: []EnumValue{ 104 {Value: "\"FullDocumentation\""}, 105 {Value: "\"NoDocumentation\""}, 106 {Value: "\"SingleLine\""}, 107 { 108 Value: "\"Structured\"", 109 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", 110 }, 111 {Value: "\"SynopsisDocumentation\""}, 112 }, 113 Default: "\"FullDocumentation\"", 114 Hierarchy: "ui.documentation", 115 }, 116 { 117 Name: "linkTarget", 118 Type: "string", 119 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", 120 Default: "\"pkg.go.dev\"", 121 Hierarchy: "ui.documentation", 122 }, 123 { 124 Name: "linksInHover", 125 Type: "bool", 126 Doc: "linksInHover toggles the presence of links to documentation in hover.\n", 127 Default: "true", 128 Hierarchy: "ui.documentation", 129 }, 130 { 131 Name: "usePlaceholders", 132 Type: "bool", 133 Doc: "placeholders enables placeholders for function parameters or struct\nfields in completion responses.\n", 134 Default: "false", 135 Hierarchy: "ui.completion", 136 }, 137 { 138 Name: "completionBudget", 139 Type: "time.Duration", 140 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", 141 Default: "\"100ms\"", 142 Status: "debug", 143 Hierarchy: "ui.completion", 144 }, 145 { 146 Name: "matcher", 147 Type: "enum", 148 Doc: "matcher sets the algorithm that is used when calculating completion\ncandidates.\n", 149 EnumValues: []EnumValue{ 150 {Value: "\"CaseInsensitive\""}, 151 {Value: "\"CaseSensitive\""}, 152 {Value: "\"Fuzzy\""}, 153 }, 154 Default: "\"Fuzzy\"", 155 Status: "advanced", 156 Hierarchy: "ui.completion", 157 }, 158 { 159 Name: "experimentalPostfixCompletions", 160 Type: "bool", 161 Doc: "experimentalPostfixCompletions enables artifical method snippets\nsuch as \"someSlice.sort!\".\n", 162 Default: "true", 163 Status: "experimental", 164 Hierarchy: "ui.completion", 165 }, 166 { 167 Name: "importShortcut", 168 Type: "enum", 169 Doc: "importShortcut specifies whether import statements should link to\ndocumentation or go to definitions.\n", 170 EnumValues: []EnumValue{ 171 {Value: "\"Both\""}, 172 {Value: "\"Definition\""}, 173 {Value: "\"Link\""}, 174 }, 175 Default: "\"Both\"", 176 Hierarchy: "ui.navigation", 177 }, 178 { 179 Name: "symbolMatcher", 180 Type: "enum", 181 Doc: "symbolMatcher sets the algorithm that is used when finding workspace symbols.\n", 182 EnumValues: []EnumValue{ 183 {Value: "\"CaseInsensitive\""}, 184 {Value: "\"CaseSensitive\""}, 185 {Value: "\"FastFuzzy\""}, 186 {Value: "\"Fuzzy\""}, 187 }, 188 Default: "\"FastFuzzy\"", 189 Status: "advanced", 190 Hierarchy: "ui.navigation", 191 }, 192 { 193 Name: "symbolStyle", 194 Type: "enum", 195 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", 196 EnumValues: []EnumValue{ 197 { 198 Value: "\"Dynamic\"", 199 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", 200 }, 201 { 202 Value: "\"Full\"", 203 Doc: "`\"Full\"` is fully qualified symbols, i.e.\n\"path/to/pkg.Foo.Field\".\n", 204 }, 205 { 206 Value: "\"Package\"", 207 Doc: "`\"Package\"` is package qualified symbols i.e.\n\"pkg.Foo.Field\".\n", 208 }, 209 }, 210 Default: "\"Dynamic\"", 211 Status: "advanced", 212 Hierarchy: "ui.navigation", 213 }, 214 { 215 Name: "analyses", 216 Type: "map[string]bool", 217 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", 218 EnumKeys: EnumKeys{ 219 ValueType: "bool", 220 Keys: []EnumKey{ 221 { 222 Name: "\"asmdecl\"", 223 Doc: "report mismatches between assembly files and Go declarations", 224 Default: "true", 225 }, 226 { 227 Name: "\"assign\"", 228 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.", 229 Default: "true", 230 }, 231 { 232 Name: "\"atomic\"", 233 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.", 234 Default: "true", 235 }, 236 { 237 Name: "\"atomicalign\"", 238 Doc: "check for non-64-bits-aligned arguments to sync/atomic functions", 239 Default: "true", 240 }, 241 { 242 Name: "\"bools\"", 243 Doc: "check for common mistakes involving boolean operators", 244 Default: "true", 245 }, 246 { 247 Name: "\"buildtag\"", 248 Doc: "check that +build tags are well-formed and correctly located", 249 Default: "true", 250 }, 251 { 252 Name: "\"cgocall\"", 253 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.", 254 Default: "true", 255 }, 256 { 257 Name: "\"composites\"", 258 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", 259 Default: "true", 260 }, 261 { 262 Name: "\"copylocks\"", 263 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.", 264 Default: "true", 265 }, 266 { 267 Name: "\"deepequalerrors\"", 268 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.", 269 Default: "true", 270 }, 271 { 272 Name: "\"errorsas\"", 273 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.", 274 Default: "true", 275 }, 276 { 277 Name: "\"fieldalignment\"", 278 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", 279 Default: "false", 280 }, 281 { 282 Name: "\"httpresponse\"", 283 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.", 284 Default: "true", 285 }, 286 { 287 Name: "\"ifaceassert\"", 288 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", 289 Default: "true", 290 }, 291 { 292 Name: "\"infertypeargs\"", 293 Doc: "check for unnecessary type arguments in call expressions\n\nExplicit type arguments may be omitted from call expressions if they can be\ninferred from function arguments, or from other type arguments:\n\n\tfunc f[T any](T) {}\n\t\n\tfunc _() {\n\t\tf[string](\"foo\") // string could be inferred\n\t}\n", 294 Default: "true", 295 }, 296 { 297 Name: "\"loopclosure\"", 298 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", 299 Default: "true", 300 }, 301 { 302 Name: "\"lostcancel\"", 303 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.)", 304 Default: "true", 305 }, 306 { 307 Name: "\"nilfunc\"", 308 Doc: "check for useless comparisons between functions and nil\n\nA useless comparison is one like f == nil as opposed to f() == nil.", 309 Default: "true", 310 }, 311 { 312 Name: "\"nilness\"", 313 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", 314 Default: "false", 315 }, 316 { 317 Name: "\"printf\"", 318 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", 319 Default: "true", 320 }, 321 { 322 Name: "\"shadow\"", 323 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", 324 Default: "false", 325 }, 326 { 327 Name: "\"shift\"", 328 Doc: "check for shifts that equal or exceed the width of the integer", 329 Default: "true", 330 }, 331 { 332 Name: "\"simplifycompositelit\"", 333 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.", 334 Default: "true", 335 }, 336 { 337 Name: "\"simplifyrange\"", 338 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.", 339 Default: "true", 340 }, 341 { 342 Name: "\"simplifyslice\"", 343 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.", 344 Default: "true", 345 }, 346 { 347 Name: "\"sortslice\"", 348 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.", 349 Default: "true", 350 }, 351 { 352 Name: "\"stdmethods\"", 353 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", 354 Default: "true", 355 }, 356 { 357 Name: "\"stringintconv\"", 358 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", 359 Default: "true", 360 }, 361 { 362 Name: "\"structtag\"", 363 Doc: "check that struct field tags conform to reflect.StructTag.Get\n\nAlso report certain struct tags (json, xml) used with unexported fields.", 364 Default: "true", 365 }, 366 { 367 Name: "\"testinggoroutine\"", 368 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", 369 Default: "true", 370 }, 371 { 372 Name: "\"tests\"", 373 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.", 374 Default: "true", 375 }, 376 { 377 Name: "\"unmarshal\"", 378 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.", 379 Default: "true", 380 }, 381 { 382 Name: "\"unreachable\"", 383 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.", 384 Default: "true", 385 }, 386 { 387 Name: "\"unsafeptr\"", 388 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.", 389 Default: "true", 390 }, 391 { 392 Name: "\"unusedparams\"", 393 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", 394 Default: "false", 395 }, 396 { 397 Name: "\"unusedresult\"", 398 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.", 399 Default: "true", 400 }, 401 { 402 Name: "\"unusedwrite\"", 403 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", 404 Default: "false", 405 }, 406 { 407 Name: "\"useany\"", 408 Doc: "check for constraints that could be simplified to \"any\"", 409 Default: "true", 410 }, 411 { 412 Name: "\"fillreturns\"", 413 Doc: "suggest fixes for errors due to an incorrect number of return values\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", 414 Default: "true", 415 }, 416 { 417 Name: "\"nonewvars\"", 418 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", 419 Default: "true", 420 }, 421 { 422 Name: "\"noresultvalues\"", 423 Doc: "suggested fixes for unexpected return values\n\nThis checker provides suggested fixes for type errors of the\ntype \"no result values expected\" or \"too many return values\".\nFor example:\n\tfunc z() { return nil }\nwill turn into\n\tfunc z() { return }\n", 424 Default: "true", 425 }, 426 { 427 Name: "\"undeclaredname\"", 428 Doc: "suggested fixes for \"undeclared name: <>\"\n\nThis checker provides suggested fixes for type errors of the\ntype \"undeclared name: <>\". It will either insert a new statement,\nsuch as:\n\n\"<> := \"\n\nor a new function declaration, such as:\n\nfunc <>(inferred parameters) {\n\tpanic(\"implement me!\")\n}\n", 429 Default: "true", 430 }, 431 { 432 Name: "\"fillstruct\"", 433 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", 434 Default: "true", 435 }, 436 { 437 Name: "\"stubmethods\"", 438 Doc: "stub methods analyzer\n\nThis analyzer generates method stubs for concrete types\nin order to implement a target interface", 439 Default: "true", 440 }, 441 }, 442 }, 443 Default: "{}", 444 Hierarchy: "ui.diagnostic", 445 }, 446 { 447 Name: "staticcheck", 448 Type: "bool", 449 Doc: "staticcheck enables additional analyses from staticcheck.io.\n", 450 Default: "false", 451 Status: "experimental", 452 Hierarchy: "ui.diagnostic", 453 }, 454 { 455 Name: "annotations", 456 Type: "map[string]bool", 457 Doc: "annotations specifies the various kinds of optimization diagnostics\nthat should be reported by the gc_details command.\n", 458 EnumKeys: EnumKeys{ 459 ValueType: "bool", 460 Keys: []EnumKey{ 461 { 462 Name: "\"bounds\"", 463 Doc: "`\"bounds\"` controls bounds checking diagnostics.\n", 464 Default: "true", 465 }, 466 { 467 Name: "\"escape\"", 468 Doc: "`\"escape\"` controls diagnostics about escape choices.\n", 469 Default: "true", 470 }, 471 { 472 Name: "\"inline\"", 473 Doc: "`\"inline\"` controls diagnostics about inlining choices.\n", 474 Default: "true", 475 }, 476 { 477 Name: "\"nil\"", 478 Doc: "`\"nil\"` controls nil checks.\n", 479 Default: "true", 480 }, 481 }, 482 }, 483 Default: "{\"bounds\":true,\"escape\":true,\"inline\":true,\"nil\":true}", 484 Status: "experimental", 485 Hierarchy: "ui.diagnostic", 486 }, 487 { 488 Name: "diagnosticsDelay", 489 Type: "time.Duration", 490 Doc: "diagnosticsDelay 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", 491 Default: "\"250ms\"", 492 Status: "advanced", 493 Hierarchy: "ui.diagnostic", 494 }, 495 { 496 Name: "experimentalWatchedFileDelay", 497 Type: "time.Duration", 498 Doc: "experimentalWatchedFileDelay controls the amount of time that gopls waits\nfor additional workspace/didChangeWatchedFiles notifications to arrive,\nbefore processing all such notifications in a single batch. This is\nintended for use by LSP clients that don't support their own batching of\nfile system notifications.\n\nThis option must be set to a valid duration string, for example `\"100ms\"`.\n", 499 Default: "\"0s\"", 500 Status: "experimental", 501 Hierarchy: "ui.diagnostic", 502 }, 503 { 504 Name: "codelenses", 505 Type: "map[string]bool", 506 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 \"codelenses\": {\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", 507 EnumKeys: EnumKeys{ 508 ValueType: "bool", 509 Keys: []EnumKey{ 510 { 511 Name: "\"gc_details\"", 512 Doc: "Toggle the calculation of gc annotations.", 513 Default: "false", 514 }, 515 { 516 Name: "\"generate\"", 517 Doc: "Runs `go generate` for a given directory.", 518 Default: "true", 519 }, 520 { 521 Name: "\"regenerate_cgo\"", 522 Doc: "Regenerates cgo definitions.", 523 Default: "true", 524 }, 525 { 526 Name: "\"test\"", 527 Doc: "Runs `go test` for a specific set of test or benchmark functions.", 528 Default: "false", 529 }, 530 { 531 Name: "\"tidy\"", 532 Doc: "Runs `go mod tidy` for a module.", 533 Default: "true", 534 }, 535 { 536 Name: "\"upgrade_dependency\"", 537 Doc: "Upgrades a dependency in the go.mod file for a module.", 538 Default: "true", 539 }, 540 { 541 Name: "\"vendor\"", 542 Doc: "Runs `go mod vendor` for a module.", 543 Default: "true", 544 }, 545 }, 546 }, 547 Default: "{\"gc_details\":false,\"generate\":true,\"regenerate_cgo\":true,\"tidy\":true,\"upgrade_dependency\":true,\"vendor\":true}", 548 Hierarchy: "ui", 549 }, 550 { 551 Name: "semanticTokens", 552 Type: "bool", 553 Doc: "semanticTokens controls whether the LSP server will send\nsemantic tokens to the client.\n", 554 Default: "false", 555 Status: "experimental", 556 Hierarchy: "ui", 557 }, 558 { 559 Name: "local", 560 Type: "string", 561 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", 562 Default: "\"\"", 563 Hierarchy: "formatting", 564 }, 565 { 566 Name: "gofumpt", 567 Type: "bool", 568 Doc: "gofumpt indicates if we should run gofumpt formatting.\n", 569 Default: "false", 570 Hierarchy: "formatting", 571 }, 572 { 573 Name: "verboseOutput", 574 Type: "bool", 575 Doc: "verboseOutput enables additional debug logging.\n", 576 Default: "false", 577 Status: "debug", 578 }, 579 }, 580 }, 581 Commands: []*CommandJSON{ 582 { 583 Command: "gopls.add_dependency", 584 Title: "Add a dependency", 585 Doc: "Adds a dependency to the go.mod file for a module.", 586 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}", 587 }, 588 { 589 Command: "gopls.add_import", 590 Title: "Add an import", 591 Doc: "Ask the server to add an import path to a given Go file. The method will\ncall applyEdit on the client so that clients don't have to apply the edit\nthemselves.", 592 ArgDoc: "{\n\t// ImportPath is the target import path that should\n\t// be added to the URI file\n\t\"ImportPath\": string,\n\t// URI is the file that the ImportPath should be\n\t// added to\n\t\"URI\": string,\n}", 593 }, 594 { 595 Command: "gopls.apply_fix", 596 Title: "Apply a fix", 597 Doc: "Applies a fix to a region of source code.", 598 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}", 599 }, 600 { 601 Command: "gopls.check_upgrades", 602 Title: "Check for upgrades", 603 Doc: "Checks for module upgrades.", 604 ArgDoc: "{\n\t// The go.mod file URI.\n\t\"URI\": string,\n\t// The modules to check.\n\t\"Modules\": []string,\n}", 605 }, 606 { 607 Command: "gopls.gc_details", 608 Title: "Toggle gc_details", 609 Doc: "Toggle the calculation of gc annotations.", 610 ArgDoc: "string", 611 }, 612 { 613 Command: "gopls.generate", 614 Title: "Run go generate", 615 Doc: "Runs `go generate` for a given directory.", 616 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}", 617 }, 618 { 619 Command: "gopls.generate_gopls_mod", 620 Title: "Generate gopls.mod", 621 Doc: "(Re)generate the gopls.mod file for a workspace.", 622 ArgDoc: "{\n\t// The file URI.\n\t\"URI\": string,\n}", 623 }, 624 { 625 Command: "gopls.go_get_package", 626 Title: "go get a package", 627 Doc: "Runs `go get` to fetch a package.", 628 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}", 629 }, 630 { 631 Command: "gopls.list_imports", 632 Title: "List imports of a file and its package", 633 Doc: "Retrieve a list of imports in the given Go file, and the package it\nbelongs to.", 634 ArgDoc: "{\n\t// The file URI.\n\t\"URI\": string,\n}", 635 ResultDoc: "{\n\t// Imports is a list of imports in the requested file.\n\t\"Imports\": []{\n\t\t\"Path\": string,\n\t\t\"Name\": string,\n\t},\n\t// PackageImports is a list of all imports in the requested file's package.\n\t\"PackageImports\": []{\n\t\t\"Path\": string,\n\t},\n}", 636 }, 637 { 638 Command: "gopls.list_known_packages", 639 Title: "List known packages", 640 Doc: "Retrieve a list of packages that are importable from the given URI.", 641 ArgDoc: "{\n\t// The file URI.\n\t\"URI\": string,\n}", 642 ResultDoc: "{\n\t// Packages is a list of packages relative\n\t// to the URIArg passed by the command request.\n\t// In other words, it omits paths that are already\n\t// imported or cannot be imported due to compiler\n\t// restrictions.\n\t\"Packages\": []string,\n}", 643 }, 644 { 645 Command: "gopls.regenerate_cgo", 646 Title: "Regenerate cgo", 647 Doc: "Regenerates cgo definitions.", 648 ArgDoc: "{\n\t// The file URI.\n\t\"URI\": string,\n}", 649 }, 650 { 651 Command: "gopls.remove_dependency", 652 Title: "Remove a dependency", 653 Doc: "Removes a dependency from the go.mod file of a module.", 654 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}", 655 }, 656 { 657 Command: "gopls.run_tests", 658 Title: "Run test(s)", 659 Doc: "Runs `go test` for a specific set of test or benchmark functions.", 660 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}", 661 }, 662 { 663 Command: "gopls.start_debugging", 664 Title: "Start the gopls debug server", 665 Doc: "Start the gopls debug server if it isn't running, and return the debug\naddress.", 666 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}", 667 ResultDoc: "{\n\t// The URLs to use to access the debug servers, for all gopls instances in\n\t// the serving path. For the common case of a single gopls instance (i.e. no\n\t// daemon), this will be exactly one address.\n\t// \n\t// In the case of one or more gopls instances forwarding the LSP to a daemon,\n\t// URLs will contain debug addresses for each server in the serving path, in\n\t// serving order. The daemon debug address will be the last entry in the\n\t// slice. If any intermediate gopls instance fails to start debugging, no\n\t// error will be returned but the debug URL for that server in the URLs slice\n\t// will be empty.\n\t\"URLs\": []string,\n}", 668 }, 669 { 670 Command: "gopls.test", 671 Title: "Run test(s) (legacy)", 672 Doc: "Runs `go test` for a specific set of test or benchmark functions.", 673 ArgDoc: "string,\n[]string,\n[]string", 674 }, 675 { 676 Command: "gopls.tidy", 677 Title: "Run go mod tidy", 678 Doc: "Runs `go mod tidy` for a module.", 679 ArgDoc: "{\n\t// The file URIs.\n\t\"URIs\": []string,\n}", 680 }, 681 { 682 Command: "gopls.toggle_gc_details", 683 Title: "Toggle gc_details", 684 Doc: "Toggle the calculation of gc annotations.", 685 ArgDoc: "{\n\t// The file URI.\n\t\"URI\": string,\n}", 686 }, 687 { 688 Command: "gopls.update_go_sum", 689 Title: "Update go.sum", 690 Doc: "Updates the go.sum file for a module.", 691 ArgDoc: "{\n\t// The file URIs.\n\t\"URIs\": []string,\n}", 692 }, 693 { 694 Command: "gopls.upgrade_dependency", 695 Title: "Upgrade a dependency", 696 Doc: "Upgrades a dependency in the go.mod file for a module.", 697 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}", 698 }, 699 { 700 Command: "gopls.vendor", 701 Title: "Run go mod vendor", 702 Doc: "Runs `go mod vendor` for a module.", 703 ArgDoc: "{\n\t// The file URI.\n\t\"URI\": string,\n}", 704 }, 705 }, 706 Lenses: []*LensJSON{ 707 { 708 Lens: "gc_details", 709 Title: "Toggle gc_details", 710 Doc: "Toggle the calculation of gc annotations.", 711 }, 712 { 713 Lens: "generate", 714 Title: "Run go generate", 715 Doc: "Runs `go generate` for a given directory.", 716 }, 717 { 718 Lens: "regenerate_cgo", 719 Title: "Regenerate cgo", 720 Doc: "Regenerates cgo definitions.", 721 }, 722 { 723 Lens: "test", 724 Title: "Run test(s) (legacy)", 725 Doc: "Runs `go test` for a specific set of test or benchmark functions.", 726 }, 727 { 728 Lens: "tidy", 729 Title: "Run go mod tidy", 730 Doc: "Runs `go mod tidy` for a module.", 731 }, 732 { 733 Lens: "upgrade_dependency", 734 Title: "Upgrade a dependency", 735 Doc: "Upgrades a dependency in the go.mod file for a module.", 736 }, 737 { 738 Lens: "vendor", 739 Title: "Run go mod vendor", 740 Doc: "Runs `go mod vendor` for a module.", 741 }, 742 }, 743 Analyzers: []*AnalyzerJSON{ 744 { 745 Name: "asmdecl", 746 Doc: "report mismatches between assembly files and Go declarations", 747 Default: true, 748 }, 749 { 750 Name: "assign", 751 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.", 752 Default: true, 753 }, 754 { 755 Name: "atomic", 756 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.", 757 Default: true, 758 }, 759 { 760 Name: "atomicalign", 761 Doc: "check for non-64-bits-aligned arguments to sync/atomic functions", 762 Default: true, 763 }, 764 { 765 Name: "bools", 766 Doc: "check for common mistakes involving boolean operators", 767 Default: true, 768 }, 769 { 770 Name: "buildtag", 771 Doc: "check that +build tags are well-formed and correctly located", 772 Default: true, 773 }, 774 { 775 Name: "cgocall", 776 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.", 777 Default: true, 778 }, 779 { 780 Name: "composites", 781 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", 782 Default: true, 783 }, 784 { 785 Name: "copylocks", 786 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.", 787 Default: true, 788 }, 789 { 790 Name: "deepequalerrors", 791 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.", 792 Default: true, 793 }, 794 { 795 Name: "errorsas", 796 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.", 797 Default: true, 798 }, 799 { 800 Name: "fieldalignment", 801 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", 802 }, 803 { 804 Name: "httpresponse", 805 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.", 806 Default: true, 807 }, 808 { 809 Name: "ifaceassert", 810 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", 811 Default: true, 812 }, 813 { 814 Name: "infertypeargs", 815 Doc: "check for unnecessary type arguments in call expressions\n\nExplicit type arguments may be omitted from call expressions if they can be\ninferred from function arguments, or from other type arguments:\n\n\tfunc f[T any](T) {}\n\t\n\tfunc _() {\n\t\tf[string](\"foo\") // string could be inferred\n\t}\n", 816 Default: true, 817 }, 818 { 819 Name: "loopclosure", 820 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", 821 Default: true, 822 }, 823 { 824 Name: "lostcancel", 825 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.)", 826 Default: true, 827 }, 828 { 829 Name: "nilfunc", 830 Doc: "check for useless comparisons between functions and nil\n\nA useless comparison is one like f == nil as opposed to f() == nil.", 831 Default: true, 832 }, 833 { 834 Name: "nilness", 835 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", 836 }, 837 { 838 Name: "printf", 839 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", 840 Default: true, 841 }, 842 { 843 Name: "shadow", 844 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", 845 }, 846 { 847 Name: "shift", 848 Doc: "check for shifts that equal or exceed the width of the integer", 849 Default: true, 850 }, 851 { 852 Name: "simplifycompositelit", 853 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.", 854 Default: true, 855 }, 856 { 857 Name: "simplifyrange", 858 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.", 859 Default: true, 860 }, 861 { 862 Name: "simplifyslice", 863 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.", 864 Default: true, 865 }, 866 { 867 Name: "sortslice", 868 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.", 869 Default: true, 870 }, 871 { 872 Name: "stdmethods", 873 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", 874 Default: true, 875 }, 876 { 877 Name: "stringintconv", 878 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", 879 Default: true, 880 }, 881 { 882 Name: "structtag", 883 Doc: "check that struct field tags conform to reflect.StructTag.Get\n\nAlso report certain struct tags (json, xml) used with unexported fields.", 884 Default: true, 885 }, 886 { 887 Name: "testinggoroutine", 888 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", 889 Default: true, 890 }, 891 { 892 Name: "tests", 893 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.", 894 Default: true, 895 }, 896 { 897 Name: "unmarshal", 898 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.", 899 Default: true, 900 }, 901 { 902 Name: "unreachable", 903 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.", 904 Default: true, 905 }, 906 { 907 Name: "unsafeptr", 908 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.", 909 Default: true, 910 }, 911 { 912 Name: "unusedparams", 913 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", 914 }, 915 { 916 Name: "unusedresult", 917 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.", 918 Default: true, 919 }, 920 { 921 Name: "unusedwrite", 922 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", 923 }, 924 { 925 Name: "useany", 926 Doc: "check for constraints that could be simplified to \"any\"", 927 Default: true, 928 }, 929 { 930 Name: "fillreturns", 931 Doc: "suggest fixes for errors due to an incorrect number of return values\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", 932 Default: true, 933 }, 934 { 935 Name: "nonewvars", 936 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", 937 Default: true, 938 }, 939 { 940 Name: "noresultvalues", 941 Doc: "suggested fixes for unexpected return values\n\nThis checker provides suggested fixes for type errors of the\ntype \"no result values expected\" or \"too many return values\".\nFor example:\n\tfunc z() { return nil }\nwill turn into\n\tfunc z() { return }\n", 942 Default: true, 943 }, 944 { 945 Name: "undeclaredname", 946 Doc: "suggested fixes for \"undeclared name: <>\"\n\nThis checker provides suggested fixes for type errors of the\ntype \"undeclared name: <>\". It will either insert a new statement,\nsuch as:\n\n\"<> := \"\n\nor a new function declaration, such as:\n\nfunc <>(inferred parameters) {\n\tpanic(\"implement me!\")\n}\n", 947 Default: true, 948 }, 949 { 950 Name: "fillstruct", 951 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", 952 Default: true, 953 }, 954 { 955 Name: "stubmethods", 956 Doc: "stub methods analyzer\n\nThis analyzer generates method stubs for concrete types\nin order to implement a target interface", 957 Default: true, 958 }, 959 }, 960 }