blob: d6fddc995e72d323c3c8725e8769c3003a0cba75 [file] [log] [blame]
Heschi Kreinicka1a1cbe2020-12-01 12:19:44 -05001// Code generated by "golang.org/x/tools/gopls/doc/generate"; DO NOT EDIT.
Heschi Kreinick50ab9672020-09-23 20:10:15 -04002
3package source
4
Heschi Kreinicka1a1cbe2020-12-01 12:19:44 -05005var GeneratedAPIJSON = &APIJSON{
6 Options: map[string][]*OptionJSON{
Heschi Kreinicka1a1cbe2020-12-01 12:19:44 -05007 "User": {
8 {
Jonathan Amsterdam8d383102021-12-13 10:33:51 -05009 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",
Heschi Kreinicka1a1cbe2020-12-01 12:19:44 -050014 },
15 {
Jonathan Amsterdam8d383102021-12-13 10:33:51 -050016 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",
Rebecca Stamblerd2d86cc2020-12-24 15:48:53 -050021 },
22 {
Jonathan Amsterdam8d383102021-12-13 10:33:51 -050023 Name: "directoryFilters",
24 Type: "[]string",
Dylan Le6fa767d2022-08-09 12:16:47 -040025 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\nDirectoryFilters also supports the `**` operator to match 0 or more directories.\n\nExamples:\n\nExclude node_modules at current depth: `-node_modules`\n\nExclude node_modules at any depth: `-**/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\"]",
Jonathan Amsterdam8d383102021-12-13 10:33:51 -050027 Hierarchy: "build",
Rebecca Stamblerd2d86cc2020-12-24 15:48:53 -050028 },
29 {
Jonathan Amsterdam8d383102021-12-13 10:33:51 -050030 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",
Robert Findleyc4cfc422022-01-06 10:14:19 -050033 Default: "[]",
Jonathan Amsterdam8d383102021-12-13 10:33:51 -050034 Hierarchy: "build",
pjwfc3ed202021-11-08 07:04:31 -050035 },
36 {
Heschi Kreinicke4354552021-04-12 18:01:18 -040037 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",
Heschi Kreinicke4354552021-04-12 18:01:18 -040040 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 },
Jonathan Amsterdam8d383102021-12-13 10:33:51 -050045 {Value: "\"Normal\""},
Heschi Kreinicke4354552021-04-12 18:01:18 -040046 },
47 Default: "\"Normal\"",
48 Status: "experimental",
49 Hierarchy: "build",
50 },
51 {
Jonathan Amsterdam8d383102021-12-13 10:33:51 -050052 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",
Rebecca Stamblerd2d86cc2020-12-24 15:48:53 -050058 },
59 {
Jonathan Amsterdam8d383102021-12-13 10:33:51 -050060 Name: "allowModfileModifications",
61 Type: "bool",
62 Doc: "allowModfileModifications disables -mod=readonly, allowing imports from\nout-of-scope modules. This option will eventually be removed.\n",
63 Default: "false",
64 Status: "experimental",
65 Hierarchy: "build",
Rebecca Stamblerd2d86cc2020-12-24 15:48:53 -050066 },
67 {
Jonathan Amsterdam8d383102021-12-13 10:33:51 -050068 Name: "allowImplicitNetworkAccess",
69 Type: "bool",
70 Doc: "allowImplicitNetworkAccess disables GOPROXY=off, allowing implicit module\ndownloads rather than requiring user action. This option will eventually\nbe removed.\n",
71 Default: "false",
72 Status: "experimental",
73 Hierarchy: "build",
Heschi Kreinicka1a1cbe2020-12-01 12:19:44 -050074 },
75 {
Robert Findleyb2533142022-10-10 13:50:45 -040076 Name: "standaloneTags",
77 Type: "[]string",
78 Doc: "standaloneTags specifies a set of build constraints that identify\nindividual Go source files that make up the entire main package of an\nexecutable.\n\nA common example of standalone main files is the convention of using the\ndirective `//go:build ignore` to denote files that are not intended to be\nincluded in any package, for example because they are invoked directly by\nthe developer using `go run`.\n\nGopls considers a file to be a standalone main file if and only if it has\npackage name \"main\" and has a build directive of the exact form\n\"//go:build tag\" or \"// +build tag\", where tag is among the list of tags\nconfigured by this setting. Notably, if the build constraint is more\ncomplicated than a simple tag (such as the composite constraint\n`//go:build tag && go1.18`), the file is not considered to be a standalone\nmain file.\n\nThis setting is only supported when gopls is built with Go 1.16 or later.\n",
79 Default: "[\"ignore\"]",
80 Hierarchy: "build",
81 },
82 {
Heschi Kreinicka1a1cbe2020-12-01 12:19:44 -050083 Name: "hoverKind",
84 Type: "enum",
85 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",
86 EnumValues: []EnumValue{
Jonathan Amsterdam8d383102021-12-13 10:33:51 -050087 {Value: "\"FullDocumentation\""},
88 {Value: "\"NoDocumentation\""},
89 {Value: "\"SingleLine\""},
Heschi Kreinicka1a1cbe2020-12-01 12:19:44 -050090 {
91 Value: "\"Structured\"",
92 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",
93 },
Jonathan Amsterdam8d383102021-12-13 10:33:51 -050094 {Value: "\"SynopsisDocumentation\""},
Heschi Kreinicka1a1cbe2020-12-01 12:19:44 -050095 },
Rebecca Stamblerd2d86cc2020-12-24 15:48:53 -050096 Default: "\"FullDocumentation\"",
Rebecca Stamblerd2d86cc2020-12-24 15:48:53 -050097 Hierarchy: "ui.documentation",
Heschi Kreinicka1a1cbe2020-12-01 12:19:44 -050098 },
99 {
Jonathan Amsterdam8d383102021-12-13 10:33:51 -0500100 Name: "linkTarget",
101 Type: "string",
Robert Findleyd01bb2f2022-07-28 13:28:39 -0400102 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\nModules matching the GOPRIVATE environment variable will not have\ndocumentation links in hover.\n",
Jonathan Amsterdam8d383102021-12-13 10:33:51 -0500103 Default: "\"pkg.go.dev\"",
104 Hierarchy: "ui.documentation",
Heschi Kreinicka1a1cbe2020-12-01 12:19:44 -0500105 },
106 {
Jonathan Amsterdam8d383102021-12-13 10:33:51 -0500107 Name: "linksInHover",
108 Type: "bool",
109 Doc: "linksInHover toggles the presence of links to documentation in hover.\n",
110 Default: "true",
111 Hierarchy: "ui.documentation",
Rebecca Stamblerd2d86cc2020-12-24 15:48:53 -0500112 },
113 {
Jonathan Amsterdam8d383102021-12-13 10:33:51 -0500114 Name: "usePlaceholders",
115 Type: "bool",
116 Doc: "placeholders enables placeholders for function parameters or struct\nfields in completion responses.\n",
117 Default: "false",
118 Hierarchy: "ui.completion",
Rebecca Stamblerd2d86cc2020-12-24 15:48:53 -0500119 },
120 {
Jonathan Amsterdam8d383102021-12-13 10:33:51 -0500121 Name: "completionBudget",
122 Type: "time.Duration",
123 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",
124 Default: "\"100ms\"",
125 Status: "debug",
126 Hierarchy: "ui.completion",
Rebecca Stamblerd2d86cc2020-12-24 15:48:53 -0500127 },
128 {
129 Name: "matcher",
130 Type: "enum",
131 Doc: "matcher sets the algorithm that is used when calculating completion\ncandidates.\n",
132 EnumValues: []EnumValue{
Jonathan Amsterdam8d383102021-12-13 10:33:51 -0500133 {Value: "\"CaseInsensitive\""},
134 {Value: "\"CaseSensitive\""},
135 {Value: "\"Fuzzy\""},
Rebecca Stamblerd2d86cc2020-12-24 15:48:53 -0500136 },
137 Default: "\"Fuzzy\"",
138 Status: "advanced",
139 Hierarchy: "ui.completion",
Heschi Kreinicka1a1cbe2020-12-01 12:19:44 -0500140 },
141 {
Jonathan Amsterdam8d383102021-12-13 10:33:51 -0500142 Name: "experimentalPostfixCompletions",
143 Type: "bool",
cuishuang78ff15e2022-03-19 13:29:11 +0000144 Doc: "experimentalPostfixCompletions enables artificial method snippets\nsuch as \"someSlice.sort!\".\n",
Jonathan Amsterdam8d383102021-12-13 10:33:51 -0500145 Default: "true",
146 Status: "experimental",
147 Hierarchy: "ui.completion",
Muir Manders94a19422021-02-24 13:37:02 -0800148 },
149 {
Heschi Kreinicka1a1cbe2020-12-01 12:19:44 -0500150 Name: "importShortcut",
151 Type: "enum",
152 Doc: "importShortcut specifies whether import statements should link to\ndocumentation or go to definitions.\n",
153 EnumValues: []EnumValue{
Jonathan Amsterdam8d383102021-12-13 10:33:51 -0500154 {Value: "\"Both\""},
155 {Value: "\"Definition\""},
156 {Value: "\"Link\""},
Heschi Kreinicka1a1cbe2020-12-01 12:19:44 -0500157 },
Rebecca Stamblerd2d86cc2020-12-24 15:48:53 -0500158 Default: "\"Both\"",
Rebecca Stamblerd2d86cc2020-12-24 15:48:53 -0500159 Hierarchy: "ui.navigation",
Heschi Kreinicka1a1cbe2020-12-01 12:19:44 -0500160 },
161 {
162 Name: "symbolMatcher",
163 Type: "enum",
164 Doc: "symbolMatcher sets the algorithm that is used when finding workspace symbols.\n",
165 EnumValues: []EnumValue{
Jonathan Amsterdam8d383102021-12-13 10:33:51 -0500166 {Value: "\"CaseInsensitive\""},
167 {Value: "\"CaseSensitive\""},
168 {Value: "\"FastFuzzy\""},
169 {Value: "\"Fuzzy\""},
Heschi Kreinicka1a1cbe2020-12-01 12:19:44 -0500170 },
Robert Findleyeeb95ae2022-02-02 09:44:54 -0500171 Default: "\"FastFuzzy\"",
Rebecca Stamblerd2d86cc2020-12-24 15:48:53 -0500172 Status: "advanced",
173 Hierarchy: "ui.navigation",
Heschi Kreinicka1a1cbe2020-12-01 12:19:44 -0500174 },
175 {
176 Name: "symbolStyle",
177 Type: "enum",
Johannes Altmanningerd39bbca2021-08-24 23:49:47 +0200178 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",
Heschi Kreinicka1a1cbe2020-12-01 12:19:44 -0500179 EnumValues: []EnumValue{
180 {
181 Value: "\"Dynamic\"",
182 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",
183 },
184 {
185 Value: "\"Full\"",
186 Doc: "`\"Full\"` is fully qualified symbols, i.e.\n\"path/to/pkg.Foo.Field\".\n",
187 },
188 {
189 Value: "\"Package\"",
190 Doc: "`\"Package\"` is package qualified symbols i.e.\n\"pkg.Foo.Field\".\n",
191 },
192 },
Rebecca Stamblerd2d86cc2020-12-24 15:48:53 -0500193 Default: "\"Dynamic\"",
194 Status: "advanced",
195 Hierarchy: "ui.navigation",
Heschi Kreinicka1a1cbe2020-12-01 12:19:44 -0500196 },
Heschi Kreinickcc330812020-12-02 21:06:38 -0500197 {
Rob Findley8e9b1852023-05-01 12:44:43 -0400198 Name: "symbolScope",
199 Type: "enum",
200 Doc: "symbolScope controls which packages are searched for workspace/symbol\nrequests. The default value, \"workspace\", searches only workspace\npackages. The legacy behavior, \"all\", causes all loaded packages to be\nsearched, including dependencies; this is more expensive and may return\nunwanted results.\n",
201 EnumValues: []EnumValue{
202 {
203 Value: "\"all\"",
204 Doc: "`\"all\"` matches symbols in any loaded package, including\ndependencies.\n",
205 },
206 {
207 Value: "\"workspace\"",
208 Doc: "`\"workspace\"` matches symbols in workspace packages only.\n",
209 },
210 },
Rob Findley4318d632023-05-10 16:23:22 -0400211 Default: "\"all\"",
Rob Findley8e9b1852023-05-01 12:44:43 -0400212 Hierarchy: "ui.navigation",
213 },
214 {
Rebecca Stambler9ca86072020-12-26 20:35:06 -0500215 Name: "analyses",
216 Type: "map[string]bool",
Robert Findley3ee17102022-09-07 13:43:00 -0400217 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 in\n[analyzers.md](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",
Rebecca Stambler9ca86072020-12-26 20:35:06 -0500218 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\"",
Russ Coxbcc77942023-01-14 17:13:29 -0500248 Doc: "check //go:build and // +build directives",
Rebecca Stambler9ca86072020-12-26 20:35:06 -0500249 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 {
Russ Coxbcc77942023-01-14 17:13:29 -0500272 Name: "\"directive\"",
273 Doc: "check Go toolchain directives such as //go:debug\n\nThis analyzer checks for problems with known Go toolchain directives\nin all Go source files in a package directory, even those excluded by\n//go:build constraints, and all non-Go source files too.\n\nFor //go:debug (see https://go.dev/doc/godebug), the analyzer checks\nthat the directives are placed only in Go source files, only above the\npackage comment, and only in package main or *_test.go files.\n\nSupport for other known directives may be added in the future.\n\nThis analyzer does not check //go:build, which is handled by the\nbuildtag analyzer.\n",
274 Default: "true",
275 },
276 {
Nooras Saba28c754d2022-04-18 18:17:15 -0400277 Name: "\"embed\"",
278 Doc: "check for //go:embed directive import\n\nThis analyzer checks that the embed package is imported when source code contains //go:embed comment directives.\nThe embed package must be imported for //go:embed directives to function.import _ \"embed\".",
279 Default: "true",
280 },
281 {
Rebecca Stambler9ca86072020-12-26 20:35:06 -0500282 Name: "\"errorsas\"",
283 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.",
284 Default: "true",
285 },
286 {
287 Name: "\"fieldalignment\"",
Alan Donovanb84d5092022-06-29 13:02:25 -0400288 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 most compact 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\nBe aware that the most compact order is not always the most efficient.\nIn rare cases it may cause two variables each updated by its own goroutine\nto occupy the same CPU cache line, inducing a form of memory contention\nknown as \"false sharing\" that slows down both goroutines.\n",
Rebecca Stambler9ca86072020-12-26 20:35:06 -0500289 Default: "false",
290 },
291 {
292 Name: "\"httpresponse\"",
293 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.",
294 Default: "true",
295 },
296 {
297 Name: "\"ifaceassert\"",
Alan Donovan255eeeb2023-03-09 10:17:50 -0500298 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.",
Rebecca Stambler9ca86072020-12-26 20:35:06 -0500299 Default: "true",
300 },
301 {
302 Name: "\"loopclosure\"",
Alan Donovan255eeeb2023-03-09 10:17:50 -0500303 Doc: "check references to loop variables from within nested functions\n\nThis analyzer reports places where a function literal references the\niteration variable of an enclosing loop, and the loop calls the function\nin such a way (e.g. with go or defer) that it may outlive the loop\niteration and possibly observe the wrong value of the variable.\n\nIn this example, all the deferred functions run after the loop has\ncompleted, so all observe the final value of v.\n\n\tfor _, v := range list {\n\t defer func() {\n\t use(v) // incorrect\n\t }()\n\t}\n\nOne fix is to create a new variable for each iteration of the loop:\n\n\tfor _, v := range list {\n\t v := v // new var per iteration\n\t defer func() {\n\t use(v) // ok\n\t }()\n\t}\n\nThe next example uses a go statement and has a similar problem.\nIn addition, it has a data race because the loop updates v\nconcurrent with the goroutines accessing it.\n\n\tfor _, v := range elem {\n\t go func() {\n\t use(v) // incorrect, and a data race\n\t }()\n\t}\n\nA fix is the same as before. The checker also reports problems\nin goroutines started by golang.org/x/sync/errgroup.Group.\nA hard-to-spot variant of this form is common in parallel tests:\n\n\tfunc Test(t *testing.T) {\n\t for _, test := range tests {\n\t t.Run(test.name, func(t *testing.T) {\n\t t.Parallel()\n\t use(test) // incorrect, and a data race\n\t })\n\t }\n\t}\n\nThe t.Parallel() call causes the rest of the function to execute\nconcurrent with the loop.\n\nThe analyzer reports references only in the last statement,\nas it is not deep enough to understand the effects of subsequent\nstatements that might render the reference benign.\n(\"Last statement\" is defined recursively in compound\nstatements such as if, switch, and select.)\n\nSee: https://golang.org/doc/go_faq.html#closures_and_goroutines",
Rebecca Stambler9ca86072020-12-26 20:35:06 -0500304 Default: "true",
305 },
306 {
307 Name: "\"lostcancel\"",
308 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.)",
309 Default: "true",
310 },
311 {
312 Name: "\"nilfunc\"",
313 Doc: "check for useless comparisons between functions and nil\n\nA useless comparison is one like f == nil as opposed to f() == nil.",
314 Default: "true",
315 },
316 {
Ainar Garipov1e524e22021-03-08 12:00:26 +0300317 Name: "\"nilness\"",
Alan Donovan255eeeb2023-03-09 10:17:50 -0500318 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}",
Ainar Garipov1e524e22021-03-08 12:00:26 +0300319 Default: "false",
320 },
321 {
Rebecca Stambler9ca86072020-12-26 20:35:06 -0500322 Name: "\"printf\"",
Alan Donovancbe66142023-03-22 09:44:16 -0400323 Doc: "check consistency of Printf format strings and arguments\n\nThe check applies to calls of the formatting functions such as\n[fmt.Printf] and [fmt.Sprintf], as well as any detected wrappers of\nthose functions.\n\nIn this example, the %d format operator requires an integer operand:\n\n\tfmt.Printf(\"%d\", \"hello\") // fmt.Printf format %d has arg \"hello\" of wrong type string\n\nSee the documentation of the fmt package for the complete set of\nformat operators and their operand types.\n\nTo enable printf checking on a function that is not found by this\nanalyzer's heuristics (for example, because control is obscured by\ndynamic method calls), insert a bogus call:\n\n\tfunc MyPrintf(format string, args ...any) {\n\t\tif false {\n\t\t\t_ = fmt.Sprintf(format, args...) // enable printf checker\n\t\t}\n\t\t...\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.",
Rebecca Stambler9ca86072020-12-26 20:35:06 -0500324 Default: "true",
325 },
326 {
327 Name: "\"shadow\"",
Alan Donovan255eeeb2023-03-09 10:17:50 -0500328 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}",
Rebecca Stambler9ca86072020-12-26 20:35:06 -0500329 Default: "false",
330 },
331 {
332 Name: "\"shift\"",
333 Doc: "check for shifts that equal or exceed the width of the integer",
334 Default: "true",
335 },
336 {
337 Name: "\"simplifycompositelit\"",
338 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.",
339 Default: "true",
340 },
341 {
342 Name: "\"simplifyrange\"",
343 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.",
344 Default: "true",
345 },
346 {
347 Name: "\"simplifyslice\"",
348 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.",
349 Default: "true",
350 },
351 {
352 Name: "\"sortslice\"",
353 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.",
354 Default: "true",
355 },
356 {
357 Name: "\"stdmethods\"",
Alan Donovan255eeeb2023-03-09 10:17:50 -0500358 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\tfunc (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\n\tFormat GobEncode GobDecode MarshalJSON MarshalXML\n\tPeek ReadByte ReadFrom ReadRune Scan Seek\n\tUnmarshalJSON UnreadByte UnreadRune WriteByte\n\tWriteTo",
Rebecca Stambler9ca86072020-12-26 20:35:06 -0500359 Default: "true",
360 },
361 {
362 Name: "\"stringintconv\"",
Alan Donovan255eeeb2023-03-09 10:17:50 -0500363 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.",
Rebecca Stambler9ca86072020-12-26 20:35:06 -0500364 Default: "true",
365 },
366 {
367 Name: "\"structtag\"",
368 Doc: "check that struct field tags conform to reflect.StructTag.Get\n\nAlso report certain struct tags (json, xml) used with unexported fields.",
369 Default: "true",
370 },
371 {
372 Name: "\"testinggoroutine\"",
Alan Donovan255eeeb2023-03-09 10:17:50 -0500373 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\n\tfunc TestFoo(t *testing.T) {\n\t go func() {\n\t t.Fatal(\"oops\") // error: (*T).Fatal called from non-test goroutine\n\t }()\n\t}",
Rebecca Stambler9ca86072020-12-26 20:35:06 -0500374 Default: "true",
375 },
376 {
377 Name: "\"tests\"",
Nooras Sabaf4e613e2023-02-24 18:00:43 -0500378 Doc: "check for common mistaken usages of tests and examples\n\nThe tests checker walks Test, Benchmark, Fuzzing 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.",
Rebecca Stambler9ca86072020-12-26 20:35:06 -0500379 Default: "true",
380 },
381 {
Erik Dubbelboer371fc672022-07-29 19:27:57 +0000382 Name: "\"timeformat\"",
Alan Donovan255eeeb2023-03-09 10:17:50 -0500383 Doc: "check for calls of (time.Time).Format or time.Parse with 2006-02-01\n\nThe timeformat checker looks for time formats with the 2006-02-01 (yyyy-dd-mm)\nformat. Internationally, \"yyyy-dd-mm\" does not occur in common calendar date\nstandards, and so it is more likely that 2006-01-02 (yyyy-mm-dd) was intended.",
Erik Dubbelboer371fc672022-07-29 19:27:57 +0000384 Default: "true",
385 },
386 {
Rebecca Stambler9ca86072020-12-26 20:35:06 -0500387 Name: "\"unmarshal\"",
388 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.",
389 Default: "true",
390 },
391 {
392 Name: "\"unreachable\"",
393 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.",
394 Default: "true",
395 },
396 {
397 Name: "\"unsafeptr\"",
Alan Donovan6d1dd122023-04-27 14:49:05 -0400398 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.",
Rebecca Stambler9ca86072020-12-26 20:35:06 -0500399 Default: "true",
400 },
401 {
402 Name: "\"unusedparams\"",
403 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",
404 Default: "false",
405 },
406 {
407 Name: "\"unusedresult\"",
Alan Donovan6d1dd122023-04-27 14:49:05 -0400408 Doc: "check for unused results of calls to some functions\n\nSome functions like fmt.Errorf return a result and have no side\neffects, so it is always a mistake to discard the result. Other\nfunctions may return an error that must not be ignored, or a cleanup\noperation that must be called. This analyzer reports calls to\nfunctions like these when the result of the call is ignored.\n\nThe set of functions may be controlled using flags.",
Rebecca Stambler9ca86072020-12-26 20:35:06 -0500409 Default: "true",
410 },
411 {
Ainar Garipovb8d1a332021-02-23 12:42:06 +0300412 Name: "\"unusedwrite\"",
Alan Donovan255eeeb2023-03-09 10:17:50 -0500413 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\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\n\tfunc (t T) f() { // t is a copy\n\t\tt.x = i // unused write to field x\n\t}",
Ainar Garipovb8d1a332021-02-23 12:42:06 +0300414 Default: "false",
415 },
416 {
Robert Findley28479582021-09-22 11:06:05 -0400417 Name: "\"useany\"",
418 Doc: "check for constraints that could be simplified to \"any\"",
Robert Findley258e4732022-02-22 10:07:30 -0500419 Default: "false",
Robert Findley28479582021-09-22 11:06:05 -0400420 },
421 {
Rebecca Stambler9ca86072020-12-26 20:35:06 -0500422 Name: "\"fillreturns\"",
Robert Findleyf64c0f42021-11-29 23:01:21 -0500423 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",
Rebecca Stambler9ca86072020-12-26 20:35:06 -0500424 Default: "true",
425 },
426 {
427 Name: "\"nonewvars\"",
428 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",
429 Default: "true",
430 },
431 {
432 Name: "\"noresultvalues\"",
Russ Coxfddb0d52022-01-18 13:51:12 -0500433 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",
Rebecca Stambler9ca86072020-12-26 20:35:06 -0500434 Default: "true",
435 },
436 {
437 Name: "\"undeclaredname\"",
Rebecca Stambler7898fe62021-09-21 17:59:25 -0400438 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",
Rebecca Stambler9ca86072020-12-26 20:35:06 -0500439 Default: "true",
440 },
441 {
Francesco Renzi1a4e02f2022-03-23 01:19:43 +0100442 Name: "\"unusedvariable\"",
443 Doc: "check for unused variables\n\nThe unusedvariable analyzer suggests fixes for unused variables errors.\n",
444 Default: "false",
445 },
446 {
Rebecca Stambler9ca86072020-12-26 20:35:06 -0500447 Name: "\"fillstruct\"",
448 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",
449 Default: "true",
450 },
Marwan Sulaiman70c3ea22021-09-16 17:26:44 -0400451 {
Robert Findleyc64bb762023-02-28 15:08:31 -0500452 Name: "\"infertypeargs\"",
453 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",
454 Default: "true",
455 },
456 {
Marwan Sulaiman70c3ea22021-09-16 17:26:44 -0400457 Name: "\"stubmethods\"",
458 Doc: "stub methods analyzer\n\nThis analyzer generates method stubs for concrete types\nin order to implement a target interface",
459 Default: "true",
460 },
Rebecca Stambler9ca86072020-12-26 20:35:06 -0500461 },
462 },
Jonathan Amsterdam8d383102021-12-13 10:33:51 -0500463 Default: "{}",
464 Hierarchy: "ui.diagnostic",
Rebecca Stamblerd2d86cc2020-12-24 15:48:53 -0500465 },
466 {
Jonathan Amsterdam8d383102021-12-13 10:33:51 -0500467 Name: "staticcheck",
468 Type: "bool",
Robert Findley3ee17102022-09-07 13:43:00 -0400469 Doc: "staticcheck enables additional analyses from staticcheck.io.\nThese analyses are documented on\n[Staticcheck's website](https://staticcheck.io/docs/checks/).\n",
Jonathan Amsterdam8d383102021-12-13 10:33:51 -0500470 Default: "false",
471 Status: "experimental",
472 Hierarchy: "ui.diagnostic",
Rebecca Stamblerd2d86cc2020-12-24 15:48:53 -0500473 },
474 {
475 Name: "annotations",
476 Type: "map[string]bool",
477 Doc: "annotations specifies the various kinds of optimization diagnostics\nthat should be reported by the gc_details command.\n",
Rebecca Stambler9ca86072020-12-26 20:35:06 -0500478 EnumKeys: EnumKeys{
479 ValueType: "bool",
480 Keys: []EnumKey{
481 {
482 Name: "\"bounds\"",
483 Doc: "`\"bounds\"` controls bounds checking diagnostics.\n",
484 Default: "true",
485 },
486 {
487 Name: "\"escape\"",
488 Doc: "`\"escape\"` controls diagnostics about escape choices.\n",
489 Default: "true",
490 },
491 {
492 Name: "\"inline\"",
493 Doc: "`\"inline\"` controls diagnostics about inlining choices.\n",
494 Default: "true",
495 },
496 {
497 Name: "\"nil\"",
498 Doc: "`\"nil\"` controls nil checks.\n",
499 Default: "true",
500 },
Rebecca Stamblerd2d86cc2020-12-24 15:48:53 -0500501 },
502 },
Jonathan Amsterdam8d383102021-12-13 10:33:51 -0500503 Default: "{\"bounds\":true,\"escape\":true,\"inline\":true,\"nil\":true}",
504 Status: "experimental",
505 Hierarchy: "ui.diagnostic",
Rebecca Stamblerd2d86cc2020-12-24 15:48:53 -0500506 },
507 {
Hana (Hyang-Ah) Kim95193682022-11-22 22:19:30 -0500508 Name: "vulncheck",
509 Type: "enum",
510 Doc: "vulncheck enables vulnerability scanning.\n",
511 EnumValues: []EnumValue{
512 {
513 Value: "\"Imports\"",
514 Doc: "`\"Imports\"`: In Imports mode, `gopls` will report vulnerabilities that affect packages\ndirectly and indirectly used by the analyzed main module.\n",
515 },
516 {
517 Value: "\"Off\"",
518 Doc: "`\"Off\"`: Disable vulnerability analysis.\n",
519 },
520 },
521 Default: "\"Off\"",
522 Status: "experimental",
523 Hierarchy: "ui.diagnostic",
524 },
525 {
Jonathan Amsterdam8d383102021-12-13 10:33:51 -0500526 Name: "diagnosticsDelay",
527 Type: "time.Duration",
528 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",
Robert Findleyc4b943d2023-03-14 13:18:21 -0400529 Default: "\"1s\"",
Jonathan Amsterdam8d383102021-12-13 10:33:51 -0500530 Status: "advanced",
531 Hierarchy: "ui.diagnostic",
Rebecca Stamblerd2d86cc2020-12-24 15:48:53 -0500532 },
533 {
Suzy Mueller871637b2022-06-13 19:25:46 -0400534 Name: "hints",
535 Type: "map[string]bool",
Robert Findley3ee17102022-09-07 13:43:00 -0400536 Doc: "hints specify inlay hints that users want to see. A full list of hints\nthat gopls uses can be found in\n[inlayHints.md](https://github.com/golang/tools/blob/master/gopls/doc/inlayHints.md).\n",
Suzy Mueller871637b2022-06-13 19:25:46 -0400537 EnumKeys: EnumKeys{Keys: []EnumKey{
538 {
Jamal Carvalho60ca6362022-06-24 17:11:38 +0000539 Name: "\"assignVariableTypes\"",
Suzy Muellerc83f42d2022-07-26 12:16:16 -0400540 Doc: "Enable/disable inlay hints for variable types in assign statements:\n```go\n\ti/* int*/, j/* int*/ := 0, len(r)-1\n```",
Suzy Mueller871637b2022-06-13 19:25:46 -0400541 Default: "false",
542 },
543 {
Jamal Carvalho60ca6362022-06-24 17:11:38 +0000544 Name: "\"compositeLiteralFields\"",
Suzy Muellerc83f42d2022-07-26 12:16:16 -0400545 Doc: "Enable/disable inlay hints for composite literal field names:\n```go\n\t{/*in: */\"Hello, world\", /*want: */\"dlrow ,olleH\"}\n```",
Suzy Mueller871637b2022-06-13 19:25:46 -0400546 Default: "false",
547 },
548 {
Jamal Carvalho60ca6362022-06-24 17:11:38 +0000549 Name: "\"compositeLiteralTypes\"",
Suzy Muellerc83f42d2022-07-26 12:16:16 -0400550 Doc: "Enable/disable inlay hints for composite literal types:\n```go\n\tfor _, c := range []struct {\n\t\tin, want string\n\t}{\n\t\t/*struct{ in string; want string }*/{\"Hello, world\", \"dlrow ,olleH\"},\n\t}\n```",
Suzy Mueller871637b2022-06-13 19:25:46 -0400551 Default: "false",
552 },
553 {
Jamal Carvalho60ca6362022-06-24 17:11:38 +0000554 Name: "\"constantValues\"",
Suzy Muellerc83f42d2022-07-26 12:16:16 -0400555 Doc: "Enable/disable inlay hints for constant values:\n```go\n\tconst (\n\t\tKindNone Kind = iota/* = 0*/\n\t\tKindPrint/* = 1*/\n\t\tKindPrintf/* = 2*/\n\t\tKindErrorf/* = 3*/\n\t)\n```",
Suzy Mueller871637b2022-06-13 19:25:46 -0400556 Default: "false",
557 },
558 {
Jamal Carvalho60ca6362022-06-24 17:11:38 +0000559 Name: "\"functionTypeParameters\"",
Suzy Muellerc83f42d2022-07-26 12:16:16 -0400560 Doc: "Enable/disable inlay hints for implicit type parameters on generic functions:\n```go\n\tmyFoo/*[int, string]*/(1, \"hello\")\n```",
Suzy Mueller871637b2022-06-13 19:25:46 -0400561 Default: "false",
562 },
563 {
Jamal Carvalho60ca6362022-06-24 17:11:38 +0000564 Name: "\"parameterNames\"",
Suzy Muellerc83f42d2022-07-26 12:16:16 -0400565 Doc: "Enable/disable inlay hints for parameter names:\n```go\n\tparseInt(/* str: */ \"123\", /* radix: */ 8)\n```",
Suzy Mueller871637b2022-06-13 19:25:46 -0400566 Default: "false",
567 },
568 {
Jamal Carvalho60ca6362022-06-24 17:11:38 +0000569 Name: "\"rangeVariableTypes\"",
Suzy Muellerc83f42d2022-07-26 12:16:16 -0400570 Doc: "Enable/disable inlay hints for variable types in range statements:\n```go\n\tfor k/* int*/, v/* string*/ := range []string{} {\n\t\tfmt.Println(k, v)\n\t}\n```",
Suzy Mueller871637b2022-06-13 19:25:46 -0400571 Default: "false",
572 },
573 }},
574 Default: "{}",
575 Status: "experimental",
576 Hierarchy: "ui.inlayhint",
577 },
578 {
Rebecca Stambler9ca86072020-12-26 20:35:06 -0500579 Name: "codelenses",
580 Type: "map[string]bool",
Robert Findley9814b1b2022-03-18 17:08:55 -0400581 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#code-lenses)\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",
Rebecca Stambler9ca86072020-12-26 20:35:06 -0500582 EnumKeys: EnumKeys{
583 ValueType: "bool",
584 Keys: []EnumKey{
585 {
Rob Findley5ab06b02021-02-08 10:03:25 -0500586 Name: "\"gc_details\"",
Rob Findley8aef11f2021-02-05 17:55:31 -0500587 Doc: "Toggle the calculation of gc annotations.",
Rob Findley5ab06b02021-02-08 10:03:25 -0500588 Default: "false",
589 },
590 {
Rebecca Stambler9ca86072020-12-26 20:35:06 -0500591 Name: "\"generate\"",
Rob Findley8aef11f2021-02-05 17:55:31 -0500592 Doc: "Runs `go generate` for a given directory.",
Rebecca Stambler9ca86072020-12-26 20:35:06 -0500593 Default: "true",
594 },
595 {
596 Name: "\"regenerate_cgo\"",
Rob Findley8aef11f2021-02-05 17:55:31 -0500597 Doc: "Regenerates cgo definitions.",
Rebecca Stambler9ca86072020-12-26 20:35:06 -0500598 Default: "true",
599 },
600 {
Hana (Hyang-Ah) Kim0a6aa902022-11-28 09:16:55 -0500601 Name: "\"run_govulncheck\"",
Hana (Hyang-Ah) Kim6c277172022-08-02 23:15:52 -0400602 Doc: "Run vulnerability check (`govulncheck`).",
603 Default: "false",
604 },
605 {
Rebecca Stambler9ca86072020-12-26 20:35:06 -0500606 Name: "\"test\"",
Rob Findley8aef11f2021-02-05 17:55:31 -0500607 Doc: "Runs `go test` for a specific set of test or benchmark functions.",
Rebecca Stambler9ca86072020-12-26 20:35:06 -0500608 Default: "false",
609 },
610 {
611 Name: "\"tidy\"",
Rob Findley8aef11f2021-02-05 17:55:31 -0500612 Doc: "Runs `go mod tidy` for a module.",
Rebecca Stambler9ca86072020-12-26 20:35:06 -0500613 Default: "true",
614 },
615 {
616 Name: "\"upgrade_dependency\"",
Rob Findley8aef11f2021-02-05 17:55:31 -0500617 Doc: "Upgrades a dependency in the go.mod file for a module.",
Rebecca Stambler9ca86072020-12-26 20:35:06 -0500618 Default: "true",
619 },
620 {
621 Name: "\"vendor\"",
Rob Findley8aef11f2021-02-05 17:55:31 -0500622 Doc: "Runs `go mod vendor` for a module.",
Rebecca Stambler9ca86072020-12-26 20:35:06 -0500623 Default: "true",
624 },
Rebecca Stambler9ca86072020-12-26 20:35:06 -0500625 },
626 },
Jonathan Amsterdam8d383102021-12-13 10:33:51 -0500627 Default: "{\"gc_details\":false,\"generate\":true,\"regenerate_cgo\":true,\"tidy\":true,\"upgrade_dependency\":true,\"vendor\":true}",
628 Hierarchy: "ui",
Rebecca Stamblerd2d86cc2020-12-24 15:48:53 -0500629 },
630 {
Jonathan Amsterdam8d383102021-12-13 10:33:51 -0500631 Name: "semanticTokens",
632 Type: "bool",
633 Doc: "semanticTokens controls whether the LSP server will send\nsemantic tokens to the client.\n",
634 Default: "false",
635 Status: "experimental",
636 Hierarchy: "ui",
Rebecca Stamblerd2d86cc2020-12-24 15:48:53 -0500637 },
638 {
pjwbd689222022-08-04 11:40:49 -0400639 Name: "noSemanticString",
640 Type: "bool",
641 Doc: "noSemanticString turns off the sending of the semantic token 'string'\n",
642 Default: "false",
643 Status: "experimental",
644 Hierarchy: "ui",
645 },
646 {
647 Name: "noSemanticNumber",
648 Type: "bool",
649 Doc: "noSemanticNumber turns off the sending of the semantic token 'number'\n",
650 Default: "false",
651 Status: "experimental",
652 Hierarchy: "ui",
653 },
654 {
Jonathan Amsterdam8d383102021-12-13 10:33:51 -0500655 Name: "local",
656 Type: "string",
657 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",
658 Default: "\"\"",
659 Hierarchy: "formatting",
Rebecca Stamblerd2d86cc2020-12-24 15:48:53 -0500660 },
661 {
Jonathan Amsterdam8d383102021-12-13 10:33:51 -0500662 Name: "gofumpt",
663 Type: "bool",
664 Doc: "gofumpt indicates if we should run gofumpt formatting.\n",
665 Default: "false",
666 Hierarchy: "formatting",
Rebecca Stamblerd2d86cc2020-12-24 15:48:53 -0500667 },
668 {
Jonathan Amsterdam8d383102021-12-13 10:33:51 -0500669 Name: "verboseOutput",
670 Type: "bool",
671 Doc: "verboseOutput enables additional debug logging.\n",
672 Default: "false",
673 Status: "debug",
Heschi Kreinickcc330812020-12-02 21:06:38 -0500674 },
Heschi Kreinicka1a1cbe2020-12-01 12:19:44 -0500675 },
676 },
677 Commands: []*CommandJSON{
678 {
Jonathan Amsterdam8d383102021-12-13 10:33:51 -0500679 Command: "gopls.add_dependency",
680 Title: "Add a dependency",
681 Doc: "Adds a dependency to the go.mod file for a module.",
682 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}",
Rob Findley8aef11f2021-02-05 17:55:31 -0500683 },
684 {
Jonathan Amsterdam8d383102021-12-13 10:33:51 -0500685 Command: "gopls.add_import",
686 Title: "Add an import",
687 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.",
688 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}",
Rob Findley8316e562021-02-10 19:22:19 -0500689 },
690 {
Jonathan Amsterdam8d383102021-12-13 10:33:51 -0500691 Command: "gopls.apply_fix",
692 Title: "Apply a fix",
693 Doc: "Applies a fix to a region of source code.",
694 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}",
Rob Findley5ab06b02021-02-08 10:03:25 -0500695 },
696 {
Jonathan Amsterdam8d383102021-12-13 10:33:51 -0500697 Command: "gopls.check_upgrades",
698 Title: "Check for upgrades",
699 Doc: "Checks for module upgrades.",
700 ArgDoc: "{\n\t// The go.mod file URI.\n\t\"URI\": string,\n\t// The modules to check.\n\t\"Modules\": []string,\n}",
Heschi Kreinicka1a1cbe2020-12-01 12:19:44 -0500701 },
702 {
Suzy Muellerc2ddf3d2022-02-18 16:05:08 -0700703 Command: "gopls.edit_go_directive",
704 Title: "Run go mod edit -go=version",
705 Doc: "Runs `go mod edit -go=version` for a module.",
706 ArgDoc: "{\n\t// Any document URI within the relevant module.\n\t\"URI\": string,\n\t// The version to pass to `go mod edit -go`.\n\t\"Version\": string,\n}",
707 },
708 {
Hana (Hyang-Ah) Kim4ce4f932022-11-17 10:07:16 -0500709 Command: "gopls.fetch_vulncheck_result",
710 Title: "Get known vulncheck result",
711 Doc: "Fetch the result of latest vulnerability check (`govulncheck`).",
712 ArgDoc: "{\n\t// The file URI.\n\t\"URI\": string,\n}",
713 ResultDoc: "map[golang.org/x/tools/gopls/internal/lsp/protocol.DocumentURI]*golang.org/x/tools/gopls/internal/govulncheck.Result",
714 },
715 {
Jonathan Amsterdam8d383102021-12-13 10:33:51 -0500716 Command: "gopls.gc_details",
717 Title: "Toggle gc_details",
718 Doc: "Toggle the calculation of gc annotations.",
719 ArgDoc: "string",
Rob Findley5ab06b02021-02-08 10:03:25 -0500720 },
721 {
Jonathan Amsterdam8d383102021-12-13 10:33:51 -0500722 Command: "gopls.generate",
723 Title: "Run go generate",
724 Doc: "Runs `go generate` for a given directory.",
725 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}",
Rob Findley5ab06b02021-02-08 10:03:25 -0500726 },
727 {
Jonathan Amsterdam8d383102021-12-13 10:33:51 -0500728 Command: "gopls.go_get_package",
729 Title: "go get a package",
730 Doc: "Runs `go get` to fetch a package.",
731 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}",
Rob Findley5ab06b02021-02-08 10:03:25 -0500732 },
733 {
Heschi Kreinick414ec9c2022-02-04 15:23:09 -0500734 Command: "gopls.list_imports",
735 Title: "List imports of a file and its package",
736 Doc: "Retrieve a list of imports in the given Go file, and the package it\nbelongs to.",
737 ArgDoc: "{\n\t// The file URI.\n\t\"URI\": string,\n}",
738 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}",
739 },
740 {
Rob Findley490eac82021-02-10 19:22:55 -0500741 Command: "gopls.list_known_packages",
742 Title: "List known packages",
743 Doc: "Retrieve a list of packages that are importable from the given URI.",
744 ArgDoc: "{\n\t// The file URI.\n\t\"URI\": string,\n}",
745 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}",
Rob Findley8316e562021-02-10 19:22:19 -0500746 },
747 {
Robert Findleyd9c6b882023-02-16 12:44:37 -0500748 Command: "gopls.mem_stats",
749 Title: "fetch memory statistics",
750 Doc: "Call runtime.GC multiple times and return memory statistics as reported by\nruntime.MemStats.\n\nThis command is used for benchmarking, and may change in the future.",
Rob Findley1c5ccad2023-04-18 13:48:38 -0400751 ResultDoc: "{\n\t\"HeapAlloc\": uint64,\n\t\"HeapInUse\": uint64,\n\t\"TotalAlloc\": uint64,\n}",
Robert Findleyd9c6b882023-02-16 12:44:37 -0500752 },
753 {
Jonathan Amsterdam8d383102021-12-13 10:33:51 -0500754 Command: "gopls.regenerate_cgo",
755 Title: "Regenerate cgo",
756 Doc: "Regenerates cgo definitions.",
757 ArgDoc: "{\n\t// The file URI.\n\t\"URI\": string,\n}",
Heschi Kreinicka1a1cbe2020-12-01 12:19:44 -0500758 },
759 {
Jonathan Amsterdam8d383102021-12-13 10:33:51 -0500760 Command: "gopls.remove_dependency",
761 Title: "Remove a dependency",
762 Doc: "Removes a dependency from the go.mod file of a module.",
763 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}",
Rob Findley8aef11f2021-02-05 17:55:31 -0500764 },
765 {
Suzy Mueller7e129ca2022-08-17 17:26:25 -0400766 Command: "gopls.reset_go_mod_diagnostics",
767 Title: "Reset go.mod diagnostics",
768 Doc: "Reset diagnostics in the go.mod file of a module.",
Hana (Hyang-Ah) Kimb0fdb782022-12-08 10:05:38 -0500769 ArgDoc: "{\n\t\"URIArg\": {\n\t\t\"URI\": string,\n\t},\n\t// Optional: source of the diagnostics to reset.\n\t// If not set, all resettable go.mod diagnostics will be cleared.\n\t\"DiagnosticSource\": string,\n}",
Suzy Mueller7e129ca2022-08-17 17:26:25 -0400770 },
771 {
Hana (Hyang-Ah) Kim0a6aa902022-11-28 09:16:55 -0500772 Command: "gopls.run_govulncheck",
773 Title: "Run govulncheck.",
774 Doc: "Run vulnerability check (`govulncheck`).",
775 ArgDoc: "{\n\t// Any document in the directory from which govulncheck will run.\n\t\"URI\": string,\n\t// Package pattern. E.g. \"\", \".\", \"./...\".\n\t\"Pattern\": string,\n}",
776 ResultDoc: "{\n\t// Token holds the progress token for LSP workDone reporting of the vulncheck\n\t// invocation.\n\t\"Token\": interface{},\n}",
777 },
778 {
Jonathan Amsterdam8d383102021-12-13 10:33:51 -0500779 Command: "gopls.run_tests",
780 Title: "Run test(s)",
781 Doc: "Runs `go test` for a specific set of test or benchmark functions.",
782 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}",
Rob Findley5ab06b02021-02-08 10:03:25 -0500783 },
784 {
Rob Findley490eac82021-02-10 19:22:55 -0500785 Command: "gopls.start_debugging",
Rob Findley9a55cb12021-06-11 11:37:14 -0400786 Title: "Start the gopls debug server",
787 Doc: "Start the gopls debug server if it isn't running, and return the debug\naddress.",
Rob Findley490eac82021-02-10 19:22:55 -0500788 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}",
789 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}",
Rob Findley7c934842021-04-12 12:38:22 -0400790 },
791 {
Jonathan Amsterdam8d383102021-12-13 10:33:51 -0500792 Command: "gopls.test",
793 Title: "Run test(s) (legacy)",
794 Doc: "Runs `go test` for a specific set of test or benchmark functions.",
795 ArgDoc: "string,\n[]string,\n[]string",
Heschi Kreinicka1a1cbe2020-12-01 12:19:44 -0500796 },
797 {
Jonathan Amsterdam8d383102021-12-13 10:33:51 -0500798 Command: "gopls.tidy",
799 Title: "Run go mod tidy",
800 Doc: "Runs `go mod tidy` for a module.",
801 ArgDoc: "{\n\t// The file URIs.\n\t\"URIs\": []string,\n}",
Heschi Kreinicka1a1cbe2020-12-01 12:19:44 -0500802 },
803 {
Jonathan Amsterdam8d383102021-12-13 10:33:51 -0500804 Command: "gopls.toggle_gc_details",
805 Title: "Toggle gc_details",
806 Doc: "Toggle the calculation of gc annotations.",
807 ArgDoc: "{\n\t// The file URI.\n\t\"URI\": string,\n}",
Heschi Kreinicka1a1cbe2020-12-01 12:19:44 -0500808 },
809 {
Jonathan Amsterdam8d383102021-12-13 10:33:51 -0500810 Command: "gopls.update_go_sum",
811 Title: "Update go.sum",
812 Doc: "Updates the go.sum file for a module.",
813 ArgDoc: "{\n\t// The file URIs.\n\t\"URIs\": []string,\n}",
Heschi Kreinicka1a1cbe2020-12-01 12:19:44 -0500814 },
815 {
Jonathan Amsterdam8d383102021-12-13 10:33:51 -0500816 Command: "gopls.upgrade_dependency",
817 Title: "Upgrade a dependency",
818 Doc: "Upgrades a dependency in the go.mod file for a module.",
819 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}",
Heschi Kreinicka1a1cbe2020-12-01 12:19:44 -0500820 },
821 {
Jonathan Amsterdam8d383102021-12-13 10:33:51 -0500822 Command: "gopls.vendor",
823 Title: "Run go mod vendor",
824 Doc: "Runs `go mod vendor` for a module.",
825 ArgDoc: "{\n\t// The file URI.\n\t\"URI\": string,\n}",
Heschi Kreinicka1a1cbe2020-12-01 12:19:44 -0500826 },
Rob Findley1c5ccad2023-04-18 13:48:38 -0400827 {
828 Command: "gopls.workspace_stats",
829 Title: "fetch workspace statistics",
830 Doc: "Query statistics about workspace builds, modules, packages, and files.\n\nThis command is intended for internal use only, by the gopls stats\ncommand.",
831 ResultDoc: "{\n\t\"Files\": {\n\t\t\"Total\": int,\n\t\t\"Largest\": int,\n\t\t\"Errs\": int,\n\t},\n\t\"Views\": []{\n\t\t\"GoCommandVersion\": string,\n\t\t\"AllPackages\": {\n\t\t\t\"Packages\": int,\n\t\t\t\"LargestPackage\": int,\n\t\t\t\"CompiledGoFiles\": int,\n\t\t\t\"Modules\": int,\n\t\t},\n\t\t\"WorkspacePackages\": {\n\t\t\t\"Packages\": int,\n\t\t\t\"LargestPackage\": int,\n\t\t\t\"CompiledGoFiles\": int,\n\t\t\t\"Modules\": int,\n\t\t},\n\t\t\"Diagnostics\": int,\n\t},\n}",
832 },
Heschi Kreinicka1a1cbe2020-12-01 12:19:44 -0500833 },
834 Lenses: []*LensJSON{
835 {
Rob Findley5ab06b02021-02-08 10:03:25 -0500836 Lens: "gc_details",
837 Title: "Toggle gc_details",
Rob Findley8aef11f2021-02-05 17:55:31 -0500838 Doc: "Toggle the calculation of gc annotations.",
Rob Findley5ab06b02021-02-08 10:03:25 -0500839 },
840 {
Heschi Kreinicka1a1cbe2020-12-01 12:19:44 -0500841 Lens: "generate",
842 Title: "Run go generate",
Rob Findley8aef11f2021-02-05 17:55:31 -0500843 Doc: "Runs `go generate` for a given directory.",
Heschi Kreinicka1a1cbe2020-12-01 12:19:44 -0500844 },
845 {
846 Lens: "regenerate_cgo",
847 Title: "Regenerate cgo",
Rob Findley8aef11f2021-02-05 17:55:31 -0500848 Doc: "Regenerates cgo definitions.",
Heschi Kreinicka1a1cbe2020-12-01 12:19:44 -0500849 },
850 {
Hana (Hyang-Ah) Kim0a6aa902022-11-28 09:16:55 -0500851 Lens: "run_govulncheck",
852 Title: "Run govulncheck.",
Hana (Hyang-Ah) Kim6c277172022-08-02 23:15:52 -0400853 Doc: "Run vulnerability check (`govulncheck`).",
854 },
855 {
Heschi Kreinicka1a1cbe2020-12-01 12:19:44 -0500856 Lens: "test",
Rob Findley8aef11f2021-02-05 17:55:31 -0500857 Title: "Run test(s) (legacy)",
858 Doc: "Runs `go test` for a specific set of test or benchmark functions.",
Heschi Kreinicka1a1cbe2020-12-01 12:19:44 -0500859 },
860 {
861 Lens: "tidy",
862 Title: "Run go mod tidy",
Rob Findley8aef11f2021-02-05 17:55:31 -0500863 Doc: "Runs `go mod tidy` for a module.",
Heschi Kreinicka1a1cbe2020-12-01 12:19:44 -0500864 },
865 {
866 Lens: "upgrade_dependency",
Rob Findley490eac82021-02-10 19:22:55 -0500867 Title: "Upgrade a dependency",
Rob Findley8aef11f2021-02-05 17:55:31 -0500868 Doc: "Upgrades a dependency in the go.mod file for a module.",
Heschi Kreinicka1a1cbe2020-12-01 12:19:44 -0500869 },
870 {
871 Lens: "vendor",
872 Title: "Run go mod vendor",
Rob Findley8aef11f2021-02-05 17:55:31 -0500873 Doc: "Runs `go mod vendor` for a module.",
Heschi Kreinicka1a1cbe2020-12-01 12:19:44 -0500874 },
Heschi Kreinicka1a1cbe2020-12-01 12:19:44 -0500875 },
Rebecca Stamblerfbbba252020-12-25 15:10:04 -0500876 Analyzers: []*AnalyzerJSON{
877 {
878 Name: "asmdecl",
879 Doc: "report mismatches between assembly files and Go declarations",
Alan Donovane5f7ae12023-03-15 14:36:36 -0400880 URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/asmdecl",
Rebecca Stamblerfbbba252020-12-25 15:10:04 -0500881 Default: true,
882 },
883 {
884 Name: "assign",
885 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.",
Alan Donovane5f7ae12023-03-15 14:36:36 -0400886 URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/assign",
Rebecca Stamblerfbbba252020-12-25 15:10:04 -0500887 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.",
Alan Donovane5f7ae12023-03-15 14:36:36 -0400892 URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/atomic",
Rebecca Stamblerfbbba252020-12-25 15:10:04 -0500893 Default: true,
894 },
895 {
896 Name: "atomicalign",
897 Doc: "check for non-64-bits-aligned arguments to sync/atomic functions",
Alan Donovane5f7ae12023-03-15 14:36:36 -0400898 URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/atomicalign",
Rebecca Stamblerfbbba252020-12-25 15:10:04 -0500899 Default: true,
900 },
901 {
902 Name: "bools",
903 Doc: "check for common mistakes involving boolean operators",
Alan Donovane5f7ae12023-03-15 14:36:36 -0400904 URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/bools",
Rebecca Stamblerfbbba252020-12-25 15:10:04 -0500905 Default: true,
906 },
907 {
908 Name: "buildtag",
Russ Coxbcc77942023-01-14 17:13:29 -0500909 Doc: "check //go:build and // +build directives",
Alan Donovane5f7ae12023-03-15 14:36:36 -0400910 URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/buildtag",
Rebecca Stamblerfbbba252020-12-25 15:10:04 -0500911 Default: true,
912 },
913 {
914 Name: "cgocall",
915 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.",
Alan Donovane5f7ae12023-03-15 14:36:36 -0400916 URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/cgocall",
Rebecca Stamblerfbbba252020-12-25 15:10:04 -0500917 Default: true,
918 },
919 {
920 Name: "composites",
921 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",
Alan Donovane5f7ae12023-03-15 14:36:36 -0400922 URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/composites",
Rebecca Stamblerfbbba252020-12-25 15:10:04 -0500923 Default: true,
924 },
925 {
926 Name: "copylocks",
927 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.",
Alan Donovane5f7ae12023-03-15 14:36:36 -0400928 URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/copylocks",
Rebecca Stamblerfbbba252020-12-25 15:10:04 -0500929 Default: true,
930 },
931 {
932 Name: "deepequalerrors",
933 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.",
Alan Donovane5f7ae12023-03-15 14:36:36 -0400934 URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/deepequalerrors",
Rebecca Stamblerfbbba252020-12-25 15:10:04 -0500935 Default: true,
936 },
937 {
Russ Coxbcc77942023-01-14 17:13:29 -0500938 Name: "directive",
939 Doc: "check Go toolchain directives such as //go:debug\n\nThis analyzer checks for problems with known Go toolchain directives\nin all Go source files in a package directory, even those excluded by\n//go:build constraints, and all non-Go source files too.\n\nFor //go:debug (see https://go.dev/doc/godebug), the analyzer checks\nthat the directives are placed only in Go source files, only above the\npackage comment, and only in package main or *_test.go files.\n\nSupport for other known directives may be added in the future.\n\nThis analyzer does not check //go:build, which is handled by the\nbuildtag analyzer.\n",
Alan Donovane5f7ae12023-03-15 14:36:36 -0400940 URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/directive",
Russ Coxbcc77942023-01-14 17:13:29 -0500941 Default: true,
942 },
943 {
Nooras Saba28c754d2022-04-18 18:17:15 -0400944 Name: "embed",
945 Doc: "check for //go:embed directive import\n\nThis analyzer checks that the embed package is imported when source code contains //go:embed comment directives.\nThe embed package must be imported for //go:embed directives to function.import _ \"embed\".",
946 Default: true,
947 },
948 {
Rebecca Stamblerfbbba252020-12-25 15:10:04 -0500949 Name: "errorsas",
950 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.",
Alan Donovane5f7ae12023-03-15 14:36:36 -0400951 URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/errorsas",
Rebecca Stamblerfbbba252020-12-25 15:10:04 -0500952 Default: true,
953 },
954 {
Jonathan Amsterdam8d383102021-12-13 10:33:51 -0500955 Name: "fieldalignment",
Alan Donovanb84d5092022-06-29 13:02:25 -0400956 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 most compact 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\nBe aware that the most compact order is not always the most efficient.\nIn rare cases it may cause two variables each updated by its own goroutine\nto occupy the same CPU cache line, inducing a form of memory contention\nknown as \"false sharing\" that slows down both goroutines.\n",
Alan Donovane5f7ae12023-03-15 14:36:36 -0400957 URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/fieldalignment",
Rebecca Stamblerfbbba252020-12-25 15:10:04 -0500958 },
959 {
960 Name: "httpresponse",
961 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.",
Alan Donovane5f7ae12023-03-15 14:36:36 -0400962 URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/httpresponse",
Rebecca Stamblerfbbba252020-12-25 15:10:04 -0500963 Default: true,
964 },
965 {
966 Name: "ifaceassert",
Alan Donovan255eeeb2023-03-09 10:17:50 -0500967 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.",
Alan Donovane5f7ae12023-03-15 14:36:36 -0400968 URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/ifaceassert",
Rebecca Stamblerfbbba252020-12-25 15:10:04 -0500969 Default: true,
970 },
971 {
972 Name: "loopclosure",
Alan Donovan255eeeb2023-03-09 10:17:50 -0500973 Doc: "check references to loop variables from within nested functions\n\nThis analyzer reports places where a function literal references the\niteration variable of an enclosing loop, and the loop calls the function\nin such a way (e.g. with go or defer) that it may outlive the loop\niteration and possibly observe the wrong value of the variable.\n\nIn this example, all the deferred functions run after the loop has\ncompleted, so all observe the final value of v.\n\n\tfor _, v := range list {\n\t defer func() {\n\t use(v) // incorrect\n\t }()\n\t}\n\nOne fix is to create a new variable for each iteration of the loop:\n\n\tfor _, v := range list {\n\t v := v // new var per iteration\n\t defer func() {\n\t use(v) // ok\n\t }()\n\t}\n\nThe next example uses a go statement and has a similar problem.\nIn addition, it has a data race because the loop updates v\nconcurrent with the goroutines accessing it.\n\n\tfor _, v := range elem {\n\t go func() {\n\t use(v) // incorrect, and a data race\n\t }()\n\t}\n\nA fix is the same as before. The checker also reports problems\nin goroutines started by golang.org/x/sync/errgroup.Group.\nA hard-to-spot variant of this form is common in parallel tests:\n\n\tfunc Test(t *testing.T) {\n\t for _, test := range tests {\n\t t.Run(test.name, func(t *testing.T) {\n\t t.Parallel()\n\t use(test) // incorrect, and a data race\n\t })\n\t }\n\t}\n\nThe t.Parallel() call causes the rest of the function to execute\nconcurrent with the loop.\n\nThe analyzer reports references only in the last statement,\nas it is not deep enough to understand the effects of subsequent\nstatements that might render the reference benign.\n(\"Last statement\" is defined recursively in compound\nstatements such as if, switch, and select.)\n\nSee: https://golang.org/doc/go_faq.html#closures_and_goroutines",
Alan Donovane5f7ae12023-03-15 14:36:36 -0400974 URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/loopclosure",
Rebecca Stamblerfbbba252020-12-25 15:10:04 -0500975 Default: true,
976 },
977 {
978 Name: "lostcancel",
979 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.)",
Alan Donovane5f7ae12023-03-15 14:36:36 -0400980 URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/lostcancel",
Rebecca Stamblerfbbba252020-12-25 15:10:04 -0500981 Default: true,
982 },
983 {
984 Name: "nilfunc",
985 Doc: "check for useless comparisons between functions and nil\n\nA useless comparison is one like f == nil as opposed to f() == nil.",
Alan Donovane5f7ae12023-03-15 14:36:36 -0400986 URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/nilfunc",
Rebecca Stamblerfbbba252020-12-25 15:10:04 -0500987 Default: true,
988 },
989 {
Jonathan Amsterdam8d383102021-12-13 10:33:51 -0500990 Name: "nilness",
Alan Donovan255eeeb2023-03-09 10:17:50 -0500991 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}",
Alan Donovane5f7ae12023-03-15 14:36:36 -0400992 URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/nilness",
Ainar Garipov1e524e22021-03-08 12:00:26 +0300993 },
994 {
Rebecca Stamblerfbbba252020-12-25 15:10:04 -0500995 Name: "printf",
Alan Donovancbe66142023-03-22 09:44:16 -0400996 Doc: "check consistency of Printf format strings and arguments\n\nThe check applies to calls of the formatting functions such as\n[fmt.Printf] and [fmt.Sprintf], as well as any detected wrappers of\nthose functions.\n\nIn this example, the %d format operator requires an integer operand:\n\n\tfmt.Printf(\"%d\", \"hello\") // fmt.Printf format %d has arg \"hello\" of wrong type string\n\nSee the documentation of the fmt package for the complete set of\nformat operators and their operand types.\n\nTo enable printf checking on a function that is not found by this\nanalyzer's heuristics (for example, because control is obscured by\ndynamic method calls), insert a bogus call:\n\n\tfunc MyPrintf(format string, args ...any) {\n\t\tif false {\n\t\t\t_ = fmt.Sprintf(format, args...) // enable printf checker\n\t\t}\n\t\t...\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.",
Alan Donovane5f7ae12023-03-15 14:36:36 -0400997 URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/printf",
Rebecca Stamblerfbbba252020-12-25 15:10:04 -0500998 Default: true,
999 },
1000 {
Jonathan Amsterdam8d383102021-12-13 10:33:51 -05001001 Name: "shadow",
Alan Donovan255eeeb2023-03-09 10:17:50 -05001002 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}",
Alan Donovane5f7ae12023-03-15 14:36:36 -04001003 URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/shadow",
Rebecca Stamblerfbbba252020-12-25 15:10:04 -05001004 },
1005 {
1006 Name: "shift",
1007 Doc: "check for shifts that equal or exceed the width of the integer",
Alan Donovane5f7ae12023-03-15 14:36:36 -04001008 URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/shift",
Rebecca Stamblerfbbba252020-12-25 15:10:04 -05001009 Default: true,
1010 },
1011 {
1012 Name: "simplifycompositelit",
1013 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.",
1014 Default: true,
1015 },
1016 {
1017 Name: "simplifyrange",
1018 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.",
1019 Default: true,
1020 },
1021 {
1022 Name: "simplifyslice",
1023 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.",
1024 Default: true,
1025 },
1026 {
1027 Name: "sortslice",
1028 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.",
Alan Donovane5f7ae12023-03-15 14:36:36 -04001029 URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/sortslice",
Rebecca Stamblerfbbba252020-12-25 15:10:04 -05001030 Default: true,
1031 },
1032 {
1033 Name: "stdmethods",
Alan Donovan255eeeb2023-03-09 10:17:50 -05001034 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\tfunc (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\n\tFormat GobEncode GobDecode MarshalJSON MarshalXML\n\tPeek ReadByte ReadFrom ReadRune Scan Seek\n\tUnmarshalJSON UnreadByte UnreadRune WriteByte\n\tWriteTo",
Alan Donovane5f7ae12023-03-15 14:36:36 -04001035 URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/stdmethods",
Rebecca Stamblerfbbba252020-12-25 15:10:04 -05001036 Default: true,
1037 },
1038 {
1039 Name: "stringintconv",
Alan Donovan255eeeb2023-03-09 10:17:50 -05001040 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.",
Alan Donovane5f7ae12023-03-15 14:36:36 -04001041 URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/stringintconv",
Rebecca Stamblerfbbba252020-12-25 15:10:04 -05001042 Default: true,
1043 },
1044 {
1045 Name: "structtag",
1046 Doc: "check that struct field tags conform to reflect.StructTag.Get\n\nAlso report certain struct tags (json, xml) used with unexported fields.",
Alan Donovane5f7ae12023-03-15 14:36:36 -04001047 URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/structtag",
Rebecca Stamblerfbbba252020-12-25 15:10:04 -05001048 Default: true,
1049 },
1050 {
1051 Name: "testinggoroutine",
Alan Donovan255eeeb2023-03-09 10:17:50 -05001052 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\n\tfunc TestFoo(t *testing.T) {\n\t go func() {\n\t t.Fatal(\"oops\") // error: (*T).Fatal called from non-test goroutine\n\t }()\n\t}",
Alan Donovane5f7ae12023-03-15 14:36:36 -04001053 URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/testinggoroutine",
Rebecca Stamblerfbbba252020-12-25 15:10:04 -05001054 Default: true,
1055 },
1056 {
1057 Name: "tests",
Nooras Sabaf4e613e2023-02-24 18:00:43 -05001058 Doc: "check for common mistaken usages of tests and examples\n\nThe tests checker walks Test, Benchmark, Fuzzing 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.",
Alan Donovane5f7ae12023-03-15 14:36:36 -04001059 URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/tests",
Rebecca Stamblerfbbba252020-12-25 15:10:04 -05001060 Default: true,
1061 },
1062 {
Erik Dubbelboer371fc672022-07-29 19:27:57 +00001063 Name: "timeformat",
Alan Donovan255eeeb2023-03-09 10:17:50 -05001064 Doc: "check for calls of (time.Time).Format or time.Parse with 2006-02-01\n\nThe timeformat checker looks for time formats with the 2006-02-01 (yyyy-dd-mm)\nformat. Internationally, \"yyyy-dd-mm\" does not occur in common calendar date\nstandards, and so it is more likely that 2006-01-02 (yyyy-mm-dd) was intended.",
Alan Donovane5f7ae12023-03-15 14:36:36 -04001065 URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/timeformat",
Erik Dubbelboer371fc672022-07-29 19:27:57 +00001066 Default: true,
1067 },
1068 {
Rebecca Stamblerfbbba252020-12-25 15:10:04 -05001069 Name: "unmarshal",
1070 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.",
Alan Donovane5f7ae12023-03-15 14:36:36 -04001071 URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/unmarshal",
Rebecca Stamblerfbbba252020-12-25 15:10:04 -05001072 Default: true,
1073 },
1074 {
1075 Name: "unreachable",
1076 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.",
Alan Donovane5f7ae12023-03-15 14:36:36 -04001077 URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/unreachable",
Rebecca Stamblerfbbba252020-12-25 15:10:04 -05001078 Default: true,
1079 },
1080 {
1081 Name: "unsafeptr",
Alan Donovan6d1dd122023-04-27 14:49:05 -04001082 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.",
Alan Donovane5f7ae12023-03-15 14:36:36 -04001083 URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/unsafeptr",
Rebecca Stamblerfbbba252020-12-25 15:10:04 -05001084 Default: true,
1085 },
1086 {
Jonathan Amsterdam8d383102021-12-13 10:33:51 -05001087 Name: "unusedparams",
1088 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",
Rebecca Stamblerfbbba252020-12-25 15:10:04 -05001089 },
1090 {
1091 Name: "unusedresult",
Alan Donovan6d1dd122023-04-27 14:49:05 -04001092 Doc: "check for unused results of calls to some functions\n\nSome functions like fmt.Errorf return a result and have no side\neffects, so it is always a mistake to discard the result. Other\nfunctions may return an error that must not be ignored, or a cleanup\noperation that must be called. This analyzer reports calls to\nfunctions like these when the result of the call is ignored.\n\nThe set of functions may be controlled using flags.",
Alan Donovane5f7ae12023-03-15 14:36:36 -04001093 URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/unusedresult",
Rebecca Stamblerfbbba252020-12-25 15:10:04 -05001094 Default: true,
1095 },
1096 {
Jonathan Amsterdam8d383102021-12-13 10:33:51 -05001097 Name: "unusedwrite",
Alan Donovan255eeeb2023-03-09 10:17:50 -05001098 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\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\n\tfunc (t T) f() { // t is a copy\n\t\tt.x = i // unused write to field x\n\t}",
Alan Donovane5f7ae12023-03-15 14:36:36 -04001099 URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/unusedwrite",
Ainar Garipovb8d1a332021-02-23 12:42:06 +03001100 },
1101 {
Robert Findley258e4732022-02-22 10:07:30 -05001102 Name: "useany",
1103 Doc: "check for constraints that could be simplified to \"any\"",
Robert Findley28479582021-09-22 11:06:05 -04001104 },
1105 {
Rebecca Stamblerfbbba252020-12-25 15:10:04 -05001106 Name: "fillreturns",
Robert Findleyf64c0f42021-11-29 23:01:21 -05001107 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",
Rebecca Stamblerfbbba252020-12-25 15:10:04 -05001108 Default: true,
1109 },
1110 {
1111 Name: "nonewvars",
1112 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",
1113 Default: true,
1114 },
1115 {
1116 Name: "noresultvalues",
Russ Coxfddb0d52022-01-18 13:51:12 -05001117 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",
Rebecca Stamblerfbbba252020-12-25 15:10:04 -05001118 Default: true,
1119 },
1120 {
1121 Name: "undeclaredname",
Rebecca Stambler7898fe62021-09-21 17:59:25 -04001122 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",
Rebecca Stamblerfbbba252020-12-25 15:10:04 -05001123 Default: true,
1124 },
1125 {
Francesco Renzi1a4e02f2022-03-23 01:19:43 +01001126 Name: "unusedvariable",
1127 Doc: "check for unused variables\n\nThe unusedvariable analyzer suggests fixes for unused variables errors.\n",
1128 },
1129 {
Rebecca Stamblerfbbba252020-12-25 15:10:04 -05001130 Name: "fillstruct",
1131 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",
1132 Default: true,
1133 },
Marwan Sulaiman70c3ea22021-09-16 17:26:44 -04001134 {
Robert Findleyc64bb762023-02-28 15:08:31 -05001135 Name: "infertypeargs",
1136 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",
1137 Default: true,
1138 },
1139 {
Marwan Sulaiman70c3ea22021-09-16 17:26:44 -04001140 Name: "stubmethods",
1141 Doc: "stub methods analyzer\n\nThis analyzer generates method stubs for concrete types\nin order to implement a target interface",
1142 Default: true,
1143 },
Rebecca Stamblerfbbba252020-12-25 15:10:04 -05001144 },
Suzy Mueller871637b2022-06-13 19:25:46 -04001145 Hints: []*HintJSON{
1146 {
Jamal Carvalho60ca6362022-06-24 17:11:38 +00001147 Name: "assignVariableTypes",
Suzy Muellerc83f42d2022-07-26 12:16:16 -04001148 Doc: "Enable/disable inlay hints for variable types in assign statements:\n```go\n\ti/* int*/, j/* int*/ := 0, len(r)-1\n```",
Suzy Mueller871637b2022-06-13 19:25:46 -04001149 },
1150 {
Jamal Carvalho60ca6362022-06-24 17:11:38 +00001151 Name: "compositeLiteralFields",
Suzy Muellerc83f42d2022-07-26 12:16:16 -04001152 Doc: "Enable/disable inlay hints for composite literal field names:\n```go\n\t{/*in: */\"Hello, world\", /*want: */\"dlrow ,olleH\"}\n```",
Suzy Mueller871637b2022-06-13 19:25:46 -04001153 },
1154 {
Jamal Carvalho60ca6362022-06-24 17:11:38 +00001155 Name: "compositeLiteralTypes",
Suzy Muellerc83f42d2022-07-26 12:16:16 -04001156 Doc: "Enable/disable inlay hints for composite literal types:\n```go\n\tfor _, c := range []struct {\n\t\tin, want string\n\t}{\n\t\t/*struct{ in string; want string }*/{\"Hello, world\", \"dlrow ,olleH\"},\n\t}\n```",
Suzy Mueller871637b2022-06-13 19:25:46 -04001157 },
1158 {
Jamal Carvalho60ca6362022-06-24 17:11:38 +00001159 Name: "constantValues",
Suzy Muellerc83f42d2022-07-26 12:16:16 -04001160 Doc: "Enable/disable inlay hints for constant values:\n```go\n\tconst (\n\t\tKindNone Kind = iota/* = 0*/\n\t\tKindPrint/* = 1*/\n\t\tKindPrintf/* = 2*/\n\t\tKindErrorf/* = 3*/\n\t)\n```",
Suzy Mueller871637b2022-06-13 19:25:46 -04001161 },
1162 {
Jamal Carvalho60ca6362022-06-24 17:11:38 +00001163 Name: "functionTypeParameters",
Suzy Muellerc83f42d2022-07-26 12:16:16 -04001164 Doc: "Enable/disable inlay hints for implicit type parameters on generic functions:\n```go\n\tmyFoo/*[int, string]*/(1, \"hello\")\n```",
Suzy Mueller871637b2022-06-13 19:25:46 -04001165 },
1166 {
Jamal Carvalho60ca6362022-06-24 17:11:38 +00001167 Name: "parameterNames",
Suzy Muellerc83f42d2022-07-26 12:16:16 -04001168 Doc: "Enable/disable inlay hints for parameter names:\n```go\n\tparseInt(/* str: */ \"123\", /* radix: */ 8)\n```",
Suzy Mueller871637b2022-06-13 19:25:46 -04001169 },
1170 {
Jamal Carvalho60ca6362022-06-24 17:11:38 +00001171 Name: "rangeVariableTypes",
Suzy Muellerc83f42d2022-07-26 12:16:16 -04001172 Doc: "Enable/disable inlay hints for variable types in range statements:\n```go\n\tfor k/* int*/, v/* string*/ := range []string{} {\n\t\tfmt.Println(k, v)\n\t}\n```",
Suzy Mueller871637b2022-06-13 19:25:46 -04001173 },
1174 },
Heschi Kreinicka1a1cbe2020-12-01 12:19:44 -05001175}