Heschi Kreinick | a1a1cbe | 2020-12-01 12:19:44 -0500 | [diff] [blame] | 1 | // Code generated by "golang.org/x/tools/gopls/doc/generate"; DO NOT EDIT. |
Heschi Kreinick | 50ab967 | 2020-09-23 20:10:15 -0400 | [diff] [blame] | 2 | |
| 3 | package source |
| 4 | |
Heschi Kreinick | a1a1cbe | 2020-12-01 12:19:44 -0500 | [diff] [blame] | 5 | var GeneratedAPIJSON = &APIJSON{ |
| 6 | Options: map[string][]*OptionJSON{ |
Heschi Kreinick | a1a1cbe | 2020-12-01 12:19:44 -0500 | [diff] [blame] | 7 | "User": { |
| 8 | { |
Jonathan Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 9 | Name: "buildFlags", |
| 10 | Type: "[]string", |
| 11 | Doc: "buildFlags is the set of flags passed on to the build system when invoked.\nIt is applied to queries like `go list`, which is used when discovering files.\nThe most common use is to set `-tags`.\n", |
| 12 | Default: "[]", |
| 13 | Hierarchy: "build", |
Heschi Kreinick | a1a1cbe | 2020-12-01 12:19:44 -0500 | [diff] [blame] | 14 | }, |
| 15 | { |
Jonathan Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 16 | Name: "env", |
| 17 | Type: "map[string]string", |
| 18 | Doc: "env adds environment variables to external commands run by `gopls`, most notably `go list`.\n", |
| 19 | Default: "{}", |
| 20 | Hierarchy: "build", |
Rebecca Stambler | d2d86cc | 2020-12-24 15:48:53 -0500 | [diff] [blame] | 21 | }, |
| 22 | { |
Jonathan Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 23 | Name: "directoryFilters", |
| 24 | Type: "[]string", |
Dylan Le | 6fa767d | 2022-08-09 12:16:47 -0400 | [diff] [blame] | 25 | Doc: "directoryFilters can be used to exclude unwanted directories from the\nworkspace. By default, all directories are included. Filters are an\noperator, `+` to include and `-` to exclude, followed by a path prefix\nrelative to the workspace folder. They are evaluated in order, and\nthe last filter that applies to a path controls whether it is included.\nThe path prefix can be empty, so an initial `-` excludes everything.\n\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 Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 27 | Hierarchy: "build", |
Rebecca Stambler | d2d86cc | 2020-12-24 15:48:53 -0500 | [diff] [blame] | 28 | }, |
| 29 | { |
Jonathan Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 30 | Name: "templateExtensions", |
| 31 | Type: "[]string", |
| 32 | Doc: "templateExtensions gives the extensions of file names that are treateed\nas template files. (The extension\nis the part of the file name after the final dot.)\n", |
Robert Findley | c4cfc42 | 2022-01-06 10:14:19 -0500 | [diff] [blame] | 33 | Default: "[]", |
Jonathan Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 34 | Hierarchy: "build", |
pjw | fc3ed20 | 2021-11-08 07:04:31 -0500 | [diff] [blame] | 35 | }, |
| 36 | { |
Heschi Kreinick | e435455 | 2021-04-12 18:01:18 -0400 | [diff] [blame] | 37 | Name: "memoryMode", |
| 38 | Type: "enum", |
| 39 | Doc: "memoryMode controls the tradeoff `gopls` makes between memory usage and\ncorrectness.\n\nValues other than `Normal` are untested and may break in surprising ways.\n", |
Heschi Kreinick | e435455 | 2021-04-12 18:01:18 -0400 | [diff] [blame] | 40 | EnumValues: []EnumValue{ |
| 41 | { |
| 42 | Value: "\"DegradeClosed\"", |
| 43 | Doc: "`\"DegradeClosed\"`: In DegradeClosed mode, `gopls` will collect less information about\npackages without open files. As a result, features like Find\nReferences and Rename will miss results in such packages.\n", |
| 44 | }, |
Jonathan Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 45 | {Value: "\"Normal\""}, |
Heschi Kreinick | e435455 | 2021-04-12 18:01:18 -0400 | [diff] [blame] | 46 | }, |
| 47 | Default: "\"Normal\"", |
| 48 | Status: "experimental", |
| 49 | Hierarchy: "build", |
| 50 | }, |
| 51 | { |
Jonathan Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 52 | Name: "expandWorkspaceToModule", |
| 53 | Type: "bool", |
| 54 | Doc: "expandWorkspaceToModule instructs `gopls` to adjust the scope of the\nworkspace to find the best available module root. `gopls` first looks for\na go.mod file in any parent directory of the workspace folder, expanding\nthe scope to that directory if it exists. If no viable parent directory is\nfound, gopls will check if there is exactly one child directory containing\na go.mod file, narrowing the scope to that directory if it exists.\n", |
| 55 | Default: "true", |
| 56 | Status: "experimental", |
| 57 | Hierarchy: "build", |
Rebecca Stambler | d2d86cc | 2020-12-24 15:48:53 -0500 | [diff] [blame] | 58 | }, |
| 59 | { |
Jonathan Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 60 | 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 Stambler | d2d86cc | 2020-12-24 15:48:53 -0500 | [diff] [blame] | 66 | }, |
| 67 | { |
Jonathan Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 68 | 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 Kreinick | a1a1cbe | 2020-12-01 12:19:44 -0500 | [diff] [blame] | 74 | }, |
| 75 | { |
Robert Findley | b253314 | 2022-10-10 13:50:45 -0400 | [diff] [blame] | 76 | 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 Kreinick | a1a1cbe | 2020-12-01 12:19:44 -0500 | [diff] [blame] | 83 | 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 Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 87 | {Value: "\"FullDocumentation\""}, |
| 88 | {Value: "\"NoDocumentation\""}, |
| 89 | {Value: "\"SingleLine\""}, |
Heschi Kreinick | a1a1cbe | 2020-12-01 12:19:44 -0500 | [diff] [blame] | 90 | { |
| 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 Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 94 | {Value: "\"SynopsisDocumentation\""}, |
Heschi Kreinick | a1a1cbe | 2020-12-01 12:19:44 -0500 | [diff] [blame] | 95 | }, |
Rebecca Stambler | d2d86cc | 2020-12-24 15:48:53 -0500 | [diff] [blame] | 96 | Default: "\"FullDocumentation\"", |
Rebecca Stambler | d2d86cc | 2020-12-24 15:48:53 -0500 | [diff] [blame] | 97 | Hierarchy: "ui.documentation", |
Heschi Kreinick | a1a1cbe | 2020-12-01 12:19:44 -0500 | [diff] [blame] | 98 | }, |
| 99 | { |
Jonathan Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 100 | Name: "linkTarget", |
| 101 | Type: "string", |
Robert Findley | d01bb2f | 2022-07-28 13:28:39 -0400 | [diff] [blame] | 102 | 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 Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 103 | Default: "\"pkg.go.dev\"", |
| 104 | Hierarchy: "ui.documentation", |
Heschi Kreinick | a1a1cbe | 2020-12-01 12:19:44 -0500 | [diff] [blame] | 105 | }, |
| 106 | { |
Jonathan Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 107 | 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 Stambler | d2d86cc | 2020-12-24 15:48:53 -0500 | [diff] [blame] | 112 | }, |
| 113 | { |
Jonathan Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 114 | 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 Stambler | d2d86cc | 2020-12-24 15:48:53 -0500 | [diff] [blame] | 119 | }, |
| 120 | { |
Jonathan Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 121 | 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 Stambler | d2d86cc | 2020-12-24 15:48:53 -0500 | [diff] [blame] | 127 | }, |
| 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 Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 133 | {Value: "\"CaseInsensitive\""}, |
| 134 | {Value: "\"CaseSensitive\""}, |
| 135 | {Value: "\"Fuzzy\""}, |
Rebecca Stambler | d2d86cc | 2020-12-24 15:48:53 -0500 | [diff] [blame] | 136 | }, |
| 137 | Default: "\"Fuzzy\"", |
| 138 | Status: "advanced", |
| 139 | Hierarchy: "ui.completion", |
Heschi Kreinick | a1a1cbe | 2020-12-01 12:19:44 -0500 | [diff] [blame] | 140 | }, |
| 141 | { |
Jonathan Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 142 | Name: "experimentalPostfixCompletions", |
| 143 | Type: "bool", |
cuishuang | 78ff15e | 2022-03-19 13:29:11 +0000 | [diff] [blame] | 144 | Doc: "experimentalPostfixCompletions enables artificial method snippets\nsuch as \"someSlice.sort!\".\n", |
Jonathan Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 145 | Default: "true", |
| 146 | Status: "experimental", |
| 147 | Hierarchy: "ui.completion", |
Muir Manders | 94a1942 | 2021-02-24 13:37:02 -0800 | [diff] [blame] | 148 | }, |
| 149 | { |
Heschi Kreinick | a1a1cbe | 2020-12-01 12:19:44 -0500 | [diff] [blame] | 150 | 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 Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 154 | {Value: "\"Both\""}, |
| 155 | {Value: "\"Definition\""}, |
| 156 | {Value: "\"Link\""}, |
Heschi Kreinick | a1a1cbe | 2020-12-01 12:19:44 -0500 | [diff] [blame] | 157 | }, |
Rebecca Stambler | d2d86cc | 2020-12-24 15:48:53 -0500 | [diff] [blame] | 158 | Default: "\"Both\"", |
Rebecca Stambler | d2d86cc | 2020-12-24 15:48:53 -0500 | [diff] [blame] | 159 | Hierarchy: "ui.navigation", |
Heschi Kreinick | a1a1cbe | 2020-12-01 12:19:44 -0500 | [diff] [blame] | 160 | }, |
| 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 Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 166 | {Value: "\"CaseInsensitive\""}, |
| 167 | {Value: "\"CaseSensitive\""}, |
| 168 | {Value: "\"FastFuzzy\""}, |
| 169 | {Value: "\"Fuzzy\""}, |
Heschi Kreinick | a1a1cbe | 2020-12-01 12:19:44 -0500 | [diff] [blame] | 170 | }, |
Robert Findley | eeb95ae | 2022-02-02 09:44:54 -0500 | [diff] [blame] | 171 | Default: "\"FastFuzzy\"", |
Rebecca Stambler | d2d86cc | 2020-12-24 15:48:53 -0500 | [diff] [blame] | 172 | Status: "advanced", |
| 173 | Hierarchy: "ui.navigation", |
Heschi Kreinick | a1a1cbe | 2020-12-01 12:19:44 -0500 | [diff] [blame] | 174 | }, |
| 175 | { |
| 176 | Name: "symbolStyle", |
| 177 | Type: "enum", |
Johannes Altmanninger | d39bbca | 2021-08-24 23:49:47 +0200 | [diff] [blame] | 178 | 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 Kreinick | a1a1cbe | 2020-12-01 12:19:44 -0500 | [diff] [blame] | 179 | 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 Stambler | d2d86cc | 2020-12-24 15:48:53 -0500 | [diff] [blame] | 193 | Default: "\"Dynamic\"", |
| 194 | Status: "advanced", |
| 195 | Hierarchy: "ui.navigation", |
Heschi Kreinick | a1a1cbe | 2020-12-01 12:19:44 -0500 | [diff] [blame] | 196 | }, |
Heschi Kreinick | cc33081 | 2020-12-02 21:06:38 -0500 | [diff] [blame] | 197 | { |
Rob Findley | 8e9b185 | 2023-05-01 12:44:43 -0400 | [diff] [blame] | 198 | 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 Findley | 4318d63 | 2023-05-10 16:23:22 -0400 | [diff] [blame] | 211 | Default: "\"all\"", |
Rob Findley | 8e9b185 | 2023-05-01 12:44:43 -0400 | [diff] [blame] | 212 | Hierarchy: "ui.navigation", |
| 213 | }, |
| 214 | { |
Rebecca Stambler | 9ca8607 | 2020-12-26 20:35:06 -0500 | [diff] [blame] | 215 | Name: "analyses", |
| 216 | Type: "map[string]bool", |
Robert Findley | 3ee1710 | 2022-09-07 13:43:00 -0400 | [diff] [blame] | 217 | Doc: "analyses specify analyses that the user would like to enable or disable.\nA map of the names of analysis passes that should be enabled/disabled.\nA full list of analyzers that gopls uses can be found 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 Stambler | 9ca8607 | 2020-12-26 20:35:06 -0500 | [diff] [blame] | 218 | EnumKeys: EnumKeys{ |
| 219 | ValueType: "bool", |
| 220 | Keys: []EnumKey{ |
| 221 | { |
| 222 | Name: "\"asmdecl\"", |
| 223 | Doc: "report mismatches between assembly files and Go declarations", |
| 224 | Default: "true", |
| 225 | }, |
| 226 | { |
| 227 | Name: "\"assign\"", |
| 228 | Doc: "check for useless assignments\n\nThis checker reports assignments of the form x = x or a[i] = a[i].\nThese are almost always useless, and even when they aren't they are\nusually a mistake.", |
| 229 | Default: "true", |
| 230 | }, |
| 231 | { |
| 232 | Name: "\"atomic\"", |
| 233 | Doc: "check for common mistakes using the sync/atomic package\n\nThe atomic checker looks for assignment statements of the form:\n\n\tx = atomic.AddUint64(&x, 1)\n\nwhich are not atomic.", |
| 234 | Default: "true", |
| 235 | }, |
| 236 | { |
| 237 | Name: "\"atomicalign\"", |
| 238 | Doc: "check for non-64-bits-aligned arguments to sync/atomic functions", |
| 239 | Default: "true", |
| 240 | }, |
| 241 | { |
| 242 | Name: "\"bools\"", |
| 243 | Doc: "check for common mistakes involving boolean operators", |
| 244 | Default: "true", |
| 245 | }, |
| 246 | { |
| 247 | Name: "\"buildtag\"", |
Russ Cox | bcc7794 | 2023-01-14 17:13:29 -0500 | [diff] [blame] | 248 | Doc: "check //go:build and // +build directives", |
Rebecca Stambler | 9ca8607 | 2020-12-26 20:35:06 -0500 | [diff] [blame] | 249 | Default: "true", |
| 250 | }, |
| 251 | { |
| 252 | Name: "\"cgocall\"", |
| 253 | Doc: "detect some violations of the cgo pointer passing rules\n\nCheck for invalid cgo pointer passing.\nThis looks for code that uses cgo to call C code passing values\nwhose types are almost always invalid according to the cgo pointer\nsharing rules.\nSpecifically, it warns about attempts to pass a Go chan, map, func,\nor slice to C, either directly, or via a pointer, array, or struct.", |
| 254 | Default: "true", |
| 255 | }, |
| 256 | { |
| 257 | Name: "\"composites\"", |
| 258 | Doc: "check for unkeyed composite literals\n\nThis analyzer reports a diagnostic for composite literals of struct\ntypes imported from another package that do not use the field-keyed\nsyntax. Such literals are fragile because the addition of a new field\n(even if unexported) to the struct will cause compilation to fail.\n\nAs an example,\n\n\terr = &net.DNSConfigError{err}\n\nshould be replaced by:\n\n\terr = &net.DNSConfigError{Err: err}\n", |
| 259 | Default: "true", |
| 260 | }, |
| 261 | { |
| 262 | Name: "\"copylocks\"", |
| 263 | Doc: "check for locks erroneously passed by value\n\nInadvertently copying a value containing a lock, such as sync.Mutex or\nsync.WaitGroup, may cause both copies to malfunction. Generally such\nvalues should be referred to through a pointer.", |
| 264 | Default: "true", |
| 265 | }, |
| 266 | { |
| 267 | Name: "\"deepequalerrors\"", |
| 268 | Doc: "check for calls of reflect.DeepEqual on error values\n\nThe deepequalerrors checker looks for calls of the form:\n\n reflect.DeepEqual(err1, err2)\n\nwhere err1 and err2 are errors. Using reflect.DeepEqual to compare\nerrors is discouraged.", |
| 269 | Default: "true", |
| 270 | }, |
| 271 | { |
Russ Cox | bcc7794 | 2023-01-14 17:13:29 -0500 | [diff] [blame] | 272 | 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 Saba | 28c754d | 2022-04-18 18:17:15 -0400 | [diff] [blame] | 277 | 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 Stambler | 9ca8607 | 2020-12-26 20:35:06 -0500 | [diff] [blame] | 282 | 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 Donovan | b84d509 | 2022-06-29 13:02:25 -0400 | [diff] [blame] | 288 | 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 Stambler | 9ca8607 | 2020-12-26 20:35:06 -0500 | [diff] [blame] | 289 | 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 Donovan | 255eeeb | 2023-03-09 10:17:50 -0500 | [diff] [blame] | 298 | 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 Stambler | 9ca8607 | 2020-12-26 20:35:06 -0500 | [diff] [blame] | 299 | Default: "true", |
| 300 | }, |
| 301 | { |
| 302 | Name: "\"loopclosure\"", |
Alan Donovan | 255eeeb | 2023-03-09 10:17:50 -0500 | [diff] [blame] | 303 | 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 Stambler | 9ca8607 | 2020-12-26 20:35:06 -0500 | [diff] [blame] | 304 | 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 Garipov | 1e524e2 | 2021-03-08 12:00:26 +0300 | [diff] [blame] | 317 | Name: "\"nilness\"", |
Alan Donovan | 255eeeb | 2023-03-09 10:17:50 -0500 | [diff] [blame] | 318 | 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 Garipov | 1e524e2 | 2021-03-08 12:00:26 +0300 | [diff] [blame] | 319 | Default: "false", |
| 320 | }, |
| 321 | { |
Rebecca Stambler | 9ca8607 | 2020-12-26 20:35:06 -0500 | [diff] [blame] | 322 | Name: "\"printf\"", |
Alan Donovan | cbe6614 | 2023-03-22 09:44:16 -0400 | [diff] [blame] | 323 | 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 Stambler | 9ca8607 | 2020-12-26 20:35:06 -0500 | [diff] [blame] | 324 | Default: "true", |
| 325 | }, |
| 326 | { |
| 327 | Name: "\"shadow\"", |
Alan Donovan | 255eeeb | 2023-03-09 10:17:50 -0500 | [diff] [blame] | 328 | 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 Stambler | 9ca8607 | 2020-12-26 20:35:06 -0500 | [diff] [blame] | 329 | 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 Donovan | 255eeeb | 2023-03-09 10:17:50 -0500 | [diff] [blame] | 358 | 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 Stambler | 9ca8607 | 2020-12-26 20:35:06 -0500 | [diff] [blame] | 359 | Default: "true", |
| 360 | }, |
| 361 | { |
| 362 | Name: "\"stringintconv\"", |
Alan Donovan | 255eeeb | 2023-03-09 10:17:50 -0500 | [diff] [blame] | 363 | 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 Stambler | 9ca8607 | 2020-12-26 20:35:06 -0500 | [diff] [blame] | 364 | 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 Donovan | 255eeeb | 2023-03-09 10:17:50 -0500 | [diff] [blame] | 373 | 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 Stambler | 9ca8607 | 2020-12-26 20:35:06 -0500 | [diff] [blame] | 374 | Default: "true", |
| 375 | }, |
| 376 | { |
| 377 | Name: "\"tests\"", |
Nooras Saba | f4e613e | 2023-02-24 18:00:43 -0500 | [diff] [blame] | 378 | 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 Stambler | 9ca8607 | 2020-12-26 20:35:06 -0500 | [diff] [blame] | 379 | Default: "true", |
| 380 | }, |
| 381 | { |
Erik Dubbelboer | 371fc67 | 2022-07-29 19:27:57 +0000 | [diff] [blame] | 382 | Name: "\"timeformat\"", |
Alan Donovan | 255eeeb | 2023-03-09 10:17:50 -0500 | [diff] [blame] | 383 | 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 Dubbelboer | 371fc67 | 2022-07-29 19:27:57 +0000 | [diff] [blame] | 384 | Default: "true", |
| 385 | }, |
| 386 | { |
Rebecca Stambler | 9ca8607 | 2020-12-26 20:35:06 -0500 | [diff] [blame] | 387 | 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 Donovan | 6d1dd12 | 2023-04-27 14:49:05 -0400 | [diff] [blame] | 398 | 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 Stambler | 9ca8607 | 2020-12-26 20:35:06 -0500 | [diff] [blame] | 399 | 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 Donovan | 6d1dd12 | 2023-04-27 14:49:05 -0400 | [diff] [blame] | 408 | 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 Stambler | 9ca8607 | 2020-12-26 20:35:06 -0500 | [diff] [blame] | 409 | Default: "true", |
| 410 | }, |
| 411 | { |
Ainar Garipov | b8d1a33 | 2021-02-23 12:42:06 +0300 | [diff] [blame] | 412 | Name: "\"unusedwrite\"", |
Alan Donovan | 255eeeb | 2023-03-09 10:17:50 -0500 | [diff] [blame] | 413 | 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 Garipov | b8d1a33 | 2021-02-23 12:42:06 +0300 | [diff] [blame] | 414 | Default: "false", |
| 415 | }, |
| 416 | { |
Robert Findley | 2847958 | 2021-09-22 11:06:05 -0400 | [diff] [blame] | 417 | Name: "\"useany\"", |
| 418 | Doc: "check for constraints that could be simplified to \"any\"", |
Robert Findley | 258e473 | 2022-02-22 10:07:30 -0500 | [diff] [blame] | 419 | Default: "false", |
Robert Findley | 2847958 | 2021-09-22 11:06:05 -0400 | [diff] [blame] | 420 | }, |
| 421 | { |
Rebecca Stambler | 9ca8607 | 2020-12-26 20:35:06 -0500 | [diff] [blame] | 422 | Name: "\"fillreturns\"", |
Robert Findley | f64c0f4 | 2021-11-29 23:01:21 -0500 | [diff] [blame] | 423 | 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 Stambler | 9ca8607 | 2020-12-26 20:35:06 -0500 | [diff] [blame] | 424 | 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 Cox | fddb0d5 | 2022-01-18 13:51:12 -0500 | [diff] [blame] | 433 | 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 Stambler | 9ca8607 | 2020-12-26 20:35:06 -0500 | [diff] [blame] | 434 | Default: "true", |
| 435 | }, |
| 436 | { |
| 437 | Name: "\"undeclaredname\"", |
Rebecca Stambler | 7898fe6 | 2021-09-21 17:59:25 -0400 | [diff] [blame] | 438 | 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 Stambler | 9ca8607 | 2020-12-26 20:35:06 -0500 | [diff] [blame] | 439 | Default: "true", |
| 440 | }, |
| 441 | { |
Francesco Renzi | 1a4e02f | 2022-03-23 01:19:43 +0100 | [diff] [blame] | 442 | 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 Stambler | 9ca8607 | 2020-12-26 20:35:06 -0500 | [diff] [blame] | 447 | 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 Sulaiman | 70c3ea2 | 2021-09-16 17:26:44 -0400 | [diff] [blame] | 451 | { |
Robert Findley | c64bb76 | 2023-02-28 15:08:31 -0500 | [diff] [blame] | 452 | 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 Sulaiman | 70c3ea2 | 2021-09-16 17:26:44 -0400 | [diff] [blame] | 457 | 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 Stambler | 9ca8607 | 2020-12-26 20:35:06 -0500 | [diff] [blame] | 461 | }, |
| 462 | }, |
Jonathan Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 463 | Default: "{}", |
| 464 | Hierarchy: "ui.diagnostic", |
Rebecca Stambler | d2d86cc | 2020-12-24 15:48:53 -0500 | [diff] [blame] | 465 | }, |
| 466 | { |
Jonathan Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 467 | Name: "staticcheck", |
| 468 | Type: "bool", |
Robert Findley | 3ee1710 | 2022-09-07 13:43:00 -0400 | [diff] [blame] | 469 | Doc: "staticcheck enables additional analyses from staticcheck.io.\nThese analyses are documented on\n[Staticcheck's website](https://staticcheck.io/docs/checks/).\n", |
Jonathan Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 470 | Default: "false", |
| 471 | Status: "experimental", |
| 472 | Hierarchy: "ui.diagnostic", |
Rebecca Stambler | d2d86cc | 2020-12-24 15:48:53 -0500 | [diff] [blame] | 473 | }, |
| 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 Stambler | 9ca8607 | 2020-12-26 20:35:06 -0500 | [diff] [blame] | 478 | 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 Stambler | d2d86cc | 2020-12-24 15:48:53 -0500 | [diff] [blame] | 501 | }, |
| 502 | }, |
Jonathan Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 503 | Default: "{\"bounds\":true,\"escape\":true,\"inline\":true,\"nil\":true}", |
| 504 | Status: "experimental", |
| 505 | Hierarchy: "ui.diagnostic", |
Rebecca Stambler | d2d86cc | 2020-12-24 15:48:53 -0500 | [diff] [blame] | 506 | }, |
| 507 | { |
Hana (Hyang-Ah) Kim | 9519368 | 2022-11-22 22:19:30 -0500 | [diff] [blame] | 508 | 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 Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 526 | 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 Findley | c4b943d | 2023-03-14 13:18:21 -0400 | [diff] [blame] | 529 | Default: "\"1s\"", |
Jonathan Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 530 | Status: "advanced", |
| 531 | Hierarchy: "ui.diagnostic", |
Rebecca Stambler | d2d86cc | 2020-12-24 15:48:53 -0500 | [diff] [blame] | 532 | }, |
| 533 | { |
Suzy Mueller | 871637b | 2022-06-13 19:25:46 -0400 | [diff] [blame] | 534 | Name: "hints", |
| 535 | Type: "map[string]bool", |
Robert Findley | 3ee1710 | 2022-09-07 13:43:00 -0400 | [diff] [blame] | 536 | 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 Mueller | 871637b | 2022-06-13 19:25:46 -0400 | [diff] [blame] | 537 | EnumKeys: EnumKeys{Keys: []EnumKey{ |
| 538 | { |
Jamal Carvalho | 60ca636 | 2022-06-24 17:11:38 +0000 | [diff] [blame] | 539 | Name: "\"assignVariableTypes\"", |
Suzy Mueller | c83f42d | 2022-07-26 12:16:16 -0400 | [diff] [blame] | 540 | Doc: "Enable/disable inlay hints for variable types in assign statements:\n```go\n\ti/* int*/, j/* int*/ := 0, len(r)-1\n```", |
Suzy Mueller | 871637b | 2022-06-13 19:25:46 -0400 | [diff] [blame] | 541 | Default: "false", |
| 542 | }, |
| 543 | { |
Jamal Carvalho | 60ca636 | 2022-06-24 17:11:38 +0000 | [diff] [blame] | 544 | Name: "\"compositeLiteralFields\"", |
Suzy Mueller | c83f42d | 2022-07-26 12:16:16 -0400 | [diff] [blame] | 545 | Doc: "Enable/disable inlay hints for composite literal field names:\n```go\n\t{/*in: */\"Hello, world\", /*want: */\"dlrow ,olleH\"}\n```", |
Suzy Mueller | 871637b | 2022-06-13 19:25:46 -0400 | [diff] [blame] | 546 | Default: "false", |
| 547 | }, |
| 548 | { |
Jamal Carvalho | 60ca636 | 2022-06-24 17:11:38 +0000 | [diff] [blame] | 549 | Name: "\"compositeLiteralTypes\"", |
Suzy Mueller | c83f42d | 2022-07-26 12:16:16 -0400 | [diff] [blame] | 550 | 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 Mueller | 871637b | 2022-06-13 19:25:46 -0400 | [diff] [blame] | 551 | Default: "false", |
| 552 | }, |
| 553 | { |
Jamal Carvalho | 60ca636 | 2022-06-24 17:11:38 +0000 | [diff] [blame] | 554 | Name: "\"constantValues\"", |
Suzy Mueller | c83f42d | 2022-07-26 12:16:16 -0400 | [diff] [blame] | 555 | 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 Mueller | 871637b | 2022-06-13 19:25:46 -0400 | [diff] [blame] | 556 | Default: "false", |
| 557 | }, |
| 558 | { |
Jamal Carvalho | 60ca636 | 2022-06-24 17:11:38 +0000 | [diff] [blame] | 559 | Name: "\"functionTypeParameters\"", |
Suzy Mueller | c83f42d | 2022-07-26 12:16:16 -0400 | [diff] [blame] | 560 | Doc: "Enable/disable inlay hints for implicit type parameters on generic functions:\n```go\n\tmyFoo/*[int, string]*/(1, \"hello\")\n```", |
Suzy Mueller | 871637b | 2022-06-13 19:25:46 -0400 | [diff] [blame] | 561 | Default: "false", |
| 562 | }, |
| 563 | { |
Jamal Carvalho | 60ca636 | 2022-06-24 17:11:38 +0000 | [diff] [blame] | 564 | Name: "\"parameterNames\"", |
Suzy Mueller | c83f42d | 2022-07-26 12:16:16 -0400 | [diff] [blame] | 565 | Doc: "Enable/disable inlay hints for parameter names:\n```go\n\tparseInt(/* str: */ \"123\", /* radix: */ 8)\n```", |
Suzy Mueller | 871637b | 2022-06-13 19:25:46 -0400 | [diff] [blame] | 566 | Default: "false", |
| 567 | }, |
| 568 | { |
Jamal Carvalho | 60ca636 | 2022-06-24 17:11:38 +0000 | [diff] [blame] | 569 | Name: "\"rangeVariableTypes\"", |
Suzy Mueller | c83f42d | 2022-07-26 12:16:16 -0400 | [diff] [blame] | 570 | 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 Mueller | 871637b | 2022-06-13 19:25:46 -0400 | [diff] [blame] | 571 | Default: "false", |
| 572 | }, |
| 573 | }}, |
| 574 | Default: "{}", |
| 575 | Status: "experimental", |
| 576 | Hierarchy: "ui.inlayhint", |
| 577 | }, |
| 578 | { |
Rebecca Stambler | 9ca8607 | 2020-12-26 20:35:06 -0500 | [diff] [blame] | 579 | Name: "codelenses", |
| 580 | Type: "map[string]bool", |
Robert Findley | 9814b1b | 2022-03-18 17:08:55 -0400 | [diff] [blame] | 581 | 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 Stambler | 9ca8607 | 2020-12-26 20:35:06 -0500 | [diff] [blame] | 582 | EnumKeys: EnumKeys{ |
| 583 | ValueType: "bool", |
| 584 | Keys: []EnumKey{ |
| 585 | { |
Rob Findley | 5ab06b0 | 2021-02-08 10:03:25 -0500 | [diff] [blame] | 586 | Name: "\"gc_details\"", |
Rob Findley | 8aef11f | 2021-02-05 17:55:31 -0500 | [diff] [blame] | 587 | Doc: "Toggle the calculation of gc annotations.", |
Rob Findley | 5ab06b0 | 2021-02-08 10:03:25 -0500 | [diff] [blame] | 588 | Default: "false", |
| 589 | }, |
| 590 | { |
Rebecca Stambler | 9ca8607 | 2020-12-26 20:35:06 -0500 | [diff] [blame] | 591 | Name: "\"generate\"", |
Rob Findley | 8aef11f | 2021-02-05 17:55:31 -0500 | [diff] [blame] | 592 | Doc: "Runs `go generate` for a given directory.", |
Rebecca Stambler | 9ca8607 | 2020-12-26 20:35:06 -0500 | [diff] [blame] | 593 | Default: "true", |
| 594 | }, |
| 595 | { |
| 596 | Name: "\"regenerate_cgo\"", |
Rob Findley | 8aef11f | 2021-02-05 17:55:31 -0500 | [diff] [blame] | 597 | Doc: "Regenerates cgo definitions.", |
Rebecca Stambler | 9ca8607 | 2020-12-26 20:35:06 -0500 | [diff] [blame] | 598 | Default: "true", |
| 599 | }, |
| 600 | { |
Hana (Hyang-Ah) Kim | 0a6aa90 | 2022-11-28 09:16:55 -0500 | [diff] [blame] | 601 | Name: "\"run_govulncheck\"", |
Hana (Hyang-Ah) Kim | 6c27717 | 2022-08-02 23:15:52 -0400 | [diff] [blame] | 602 | Doc: "Run vulnerability check (`govulncheck`).", |
| 603 | Default: "false", |
| 604 | }, |
| 605 | { |
Rebecca Stambler | 9ca8607 | 2020-12-26 20:35:06 -0500 | [diff] [blame] | 606 | Name: "\"test\"", |
Rob Findley | 8aef11f | 2021-02-05 17:55:31 -0500 | [diff] [blame] | 607 | Doc: "Runs `go test` for a specific set of test or benchmark functions.", |
Rebecca Stambler | 9ca8607 | 2020-12-26 20:35:06 -0500 | [diff] [blame] | 608 | Default: "false", |
| 609 | }, |
| 610 | { |
| 611 | Name: "\"tidy\"", |
Rob Findley | 8aef11f | 2021-02-05 17:55:31 -0500 | [diff] [blame] | 612 | Doc: "Runs `go mod tidy` for a module.", |
Rebecca Stambler | 9ca8607 | 2020-12-26 20:35:06 -0500 | [diff] [blame] | 613 | Default: "true", |
| 614 | }, |
| 615 | { |
| 616 | Name: "\"upgrade_dependency\"", |
Rob Findley | 8aef11f | 2021-02-05 17:55:31 -0500 | [diff] [blame] | 617 | Doc: "Upgrades a dependency in the go.mod file for a module.", |
Rebecca Stambler | 9ca8607 | 2020-12-26 20:35:06 -0500 | [diff] [blame] | 618 | Default: "true", |
| 619 | }, |
| 620 | { |
| 621 | Name: "\"vendor\"", |
Rob Findley | 8aef11f | 2021-02-05 17:55:31 -0500 | [diff] [blame] | 622 | Doc: "Runs `go mod vendor` for a module.", |
Rebecca Stambler | 9ca8607 | 2020-12-26 20:35:06 -0500 | [diff] [blame] | 623 | Default: "true", |
| 624 | }, |
Rebecca Stambler | 9ca8607 | 2020-12-26 20:35:06 -0500 | [diff] [blame] | 625 | }, |
| 626 | }, |
Jonathan Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 627 | Default: "{\"gc_details\":false,\"generate\":true,\"regenerate_cgo\":true,\"tidy\":true,\"upgrade_dependency\":true,\"vendor\":true}", |
| 628 | Hierarchy: "ui", |
Rebecca Stambler | d2d86cc | 2020-12-24 15:48:53 -0500 | [diff] [blame] | 629 | }, |
| 630 | { |
Jonathan Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 631 | 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 Stambler | d2d86cc | 2020-12-24 15:48:53 -0500 | [diff] [blame] | 637 | }, |
| 638 | { |
pjw | bd68922 | 2022-08-04 11:40:49 -0400 | [diff] [blame] | 639 | 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 Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 655 | 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 Stambler | d2d86cc | 2020-12-24 15:48:53 -0500 | [diff] [blame] | 660 | }, |
| 661 | { |
Jonathan Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 662 | Name: "gofumpt", |
| 663 | Type: "bool", |
| 664 | Doc: "gofumpt indicates if we should run gofumpt formatting.\n", |
| 665 | Default: "false", |
| 666 | Hierarchy: "formatting", |
Rebecca Stambler | d2d86cc | 2020-12-24 15:48:53 -0500 | [diff] [blame] | 667 | }, |
| 668 | { |
Jonathan Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 669 | Name: "verboseOutput", |
| 670 | Type: "bool", |
| 671 | Doc: "verboseOutput enables additional debug logging.\n", |
| 672 | Default: "false", |
| 673 | Status: "debug", |
Heschi Kreinick | cc33081 | 2020-12-02 21:06:38 -0500 | [diff] [blame] | 674 | }, |
Heschi Kreinick | a1a1cbe | 2020-12-01 12:19:44 -0500 | [diff] [blame] | 675 | }, |
| 676 | }, |
| 677 | Commands: []*CommandJSON{ |
| 678 | { |
Jonathan Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 679 | 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 Findley | 8aef11f | 2021-02-05 17:55:31 -0500 | [diff] [blame] | 683 | }, |
| 684 | { |
Jonathan Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 685 | 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 Findley | 8316e56 | 2021-02-10 19:22:19 -0500 | [diff] [blame] | 689 | }, |
| 690 | { |
Jonathan Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 691 | 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 Findley | 5ab06b0 | 2021-02-08 10:03:25 -0500 | [diff] [blame] | 695 | }, |
| 696 | { |
Jonathan Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 697 | 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 Kreinick | a1a1cbe | 2020-12-01 12:19:44 -0500 | [diff] [blame] | 701 | }, |
| 702 | { |
Suzy Mueller | c2ddf3d | 2022-02-18 16:05:08 -0700 | [diff] [blame] | 703 | 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) Kim | 4ce4f93 | 2022-11-17 10:07:16 -0500 | [diff] [blame] | 709 | 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 Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 716 | Command: "gopls.gc_details", |
| 717 | Title: "Toggle gc_details", |
| 718 | Doc: "Toggle the calculation of gc annotations.", |
| 719 | ArgDoc: "string", |
Rob Findley | 5ab06b0 | 2021-02-08 10:03:25 -0500 | [diff] [blame] | 720 | }, |
| 721 | { |
Jonathan Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 722 | 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 Findley | 5ab06b0 | 2021-02-08 10:03:25 -0500 | [diff] [blame] | 726 | }, |
| 727 | { |
Jonathan Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 728 | 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 Findley | 5ab06b0 | 2021-02-08 10:03:25 -0500 | [diff] [blame] | 732 | }, |
| 733 | { |
Heschi Kreinick | 414ec9c | 2022-02-04 15:23:09 -0500 | [diff] [blame] | 734 | 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 Findley | 490eac8 | 2021-02-10 19:22:55 -0500 | [diff] [blame] | 741 | 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 Findley | 8316e56 | 2021-02-10 19:22:19 -0500 | [diff] [blame] | 746 | }, |
| 747 | { |
Robert Findley | d9c6b88 | 2023-02-16 12:44:37 -0500 | [diff] [blame] | 748 | 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 Findley | 1c5ccad | 2023-04-18 13:48:38 -0400 | [diff] [blame] | 751 | ResultDoc: "{\n\t\"HeapAlloc\": uint64,\n\t\"HeapInUse\": uint64,\n\t\"TotalAlloc\": uint64,\n}", |
Robert Findley | d9c6b88 | 2023-02-16 12:44:37 -0500 | [diff] [blame] | 752 | }, |
| 753 | { |
Jonathan Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 754 | 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 Kreinick | a1a1cbe | 2020-12-01 12:19:44 -0500 | [diff] [blame] | 758 | }, |
| 759 | { |
Jonathan Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 760 | 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 Findley | 8aef11f | 2021-02-05 17:55:31 -0500 | [diff] [blame] | 764 | }, |
| 765 | { |
Suzy Mueller | 7e129ca | 2022-08-17 17:26:25 -0400 | [diff] [blame] | 766 | 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) Kim | b0fdb78 | 2022-12-08 10:05:38 -0500 | [diff] [blame] | 769 | 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 Mueller | 7e129ca | 2022-08-17 17:26:25 -0400 | [diff] [blame] | 770 | }, |
| 771 | { |
Hana (Hyang-Ah) Kim | 0a6aa90 | 2022-11-28 09:16:55 -0500 | [diff] [blame] | 772 | 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 Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 779 | 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 Findley | 5ab06b0 | 2021-02-08 10:03:25 -0500 | [diff] [blame] | 783 | }, |
| 784 | { |
Rob Findley | 490eac8 | 2021-02-10 19:22:55 -0500 | [diff] [blame] | 785 | Command: "gopls.start_debugging", |
Rob Findley | 9a55cb1 | 2021-06-11 11:37:14 -0400 | [diff] [blame] | 786 | Title: "Start the gopls debug server", |
| 787 | Doc: "Start the gopls debug server if it isn't running, and return the debug\naddress.", |
Rob Findley | 490eac8 | 2021-02-10 19:22:55 -0500 | [diff] [blame] | 788 | 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 Findley | 7c93484 | 2021-04-12 12:38:22 -0400 | [diff] [blame] | 790 | }, |
| 791 | { |
Jonathan Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 792 | 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 Kreinick | a1a1cbe | 2020-12-01 12:19:44 -0500 | [diff] [blame] | 796 | }, |
| 797 | { |
Jonathan Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 798 | 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 Kreinick | a1a1cbe | 2020-12-01 12:19:44 -0500 | [diff] [blame] | 802 | }, |
| 803 | { |
Jonathan Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 804 | 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 Kreinick | a1a1cbe | 2020-12-01 12:19:44 -0500 | [diff] [blame] | 808 | }, |
| 809 | { |
Jonathan Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 810 | 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 Kreinick | a1a1cbe | 2020-12-01 12:19:44 -0500 | [diff] [blame] | 814 | }, |
| 815 | { |
Jonathan Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 816 | 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 Kreinick | a1a1cbe | 2020-12-01 12:19:44 -0500 | [diff] [blame] | 820 | }, |
| 821 | { |
Jonathan Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 822 | 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 Kreinick | a1a1cbe | 2020-12-01 12:19:44 -0500 | [diff] [blame] | 826 | }, |
Rob Findley | 1c5ccad | 2023-04-18 13:48:38 -0400 | [diff] [blame] | 827 | { |
| 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 Kreinick | a1a1cbe | 2020-12-01 12:19:44 -0500 | [diff] [blame] | 833 | }, |
| 834 | Lenses: []*LensJSON{ |
| 835 | { |
Rob Findley | 5ab06b0 | 2021-02-08 10:03:25 -0500 | [diff] [blame] | 836 | Lens: "gc_details", |
| 837 | Title: "Toggle gc_details", |
Rob Findley | 8aef11f | 2021-02-05 17:55:31 -0500 | [diff] [blame] | 838 | Doc: "Toggle the calculation of gc annotations.", |
Rob Findley | 5ab06b0 | 2021-02-08 10:03:25 -0500 | [diff] [blame] | 839 | }, |
| 840 | { |
Heschi Kreinick | a1a1cbe | 2020-12-01 12:19:44 -0500 | [diff] [blame] | 841 | Lens: "generate", |
| 842 | Title: "Run go generate", |
Rob Findley | 8aef11f | 2021-02-05 17:55:31 -0500 | [diff] [blame] | 843 | Doc: "Runs `go generate` for a given directory.", |
Heschi Kreinick | a1a1cbe | 2020-12-01 12:19:44 -0500 | [diff] [blame] | 844 | }, |
| 845 | { |
| 846 | Lens: "regenerate_cgo", |
| 847 | Title: "Regenerate cgo", |
Rob Findley | 8aef11f | 2021-02-05 17:55:31 -0500 | [diff] [blame] | 848 | Doc: "Regenerates cgo definitions.", |
Heschi Kreinick | a1a1cbe | 2020-12-01 12:19:44 -0500 | [diff] [blame] | 849 | }, |
| 850 | { |
Hana (Hyang-Ah) Kim | 0a6aa90 | 2022-11-28 09:16:55 -0500 | [diff] [blame] | 851 | Lens: "run_govulncheck", |
| 852 | Title: "Run govulncheck.", |
Hana (Hyang-Ah) Kim | 6c27717 | 2022-08-02 23:15:52 -0400 | [diff] [blame] | 853 | Doc: "Run vulnerability check (`govulncheck`).", |
| 854 | }, |
| 855 | { |
Heschi Kreinick | a1a1cbe | 2020-12-01 12:19:44 -0500 | [diff] [blame] | 856 | Lens: "test", |
Rob Findley | 8aef11f | 2021-02-05 17:55:31 -0500 | [diff] [blame] | 857 | Title: "Run test(s) (legacy)", |
| 858 | Doc: "Runs `go test` for a specific set of test or benchmark functions.", |
Heschi Kreinick | a1a1cbe | 2020-12-01 12:19:44 -0500 | [diff] [blame] | 859 | }, |
| 860 | { |
| 861 | Lens: "tidy", |
| 862 | Title: "Run go mod tidy", |
Rob Findley | 8aef11f | 2021-02-05 17:55:31 -0500 | [diff] [blame] | 863 | Doc: "Runs `go mod tidy` for a module.", |
Heschi Kreinick | a1a1cbe | 2020-12-01 12:19:44 -0500 | [diff] [blame] | 864 | }, |
| 865 | { |
| 866 | Lens: "upgrade_dependency", |
Rob Findley | 490eac8 | 2021-02-10 19:22:55 -0500 | [diff] [blame] | 867 | Title: "Upgrade a dependency", |
Rob Findley | 8aef11f | 2021-02-05 17:55:31 -0500 | [diff] [blame] | 868 | Doc: "Upgrades a dependency in the go.mod file for a module.", |
Heschi Kreinick | a1a1cbe | 2020-12-01 12:19:44 -0500 | [diff] [blame] | 869 | }, |
| 870 | { |
| 871 | Lens: "vendor", |
| 872 | Title: "Run go mod vendor", |
Rob Findley | 8aef11f | 2021-02-05 17:55:31 -0500 | [diff] [blame] | 873 | Doc: "Runs `go mod vendor` for a module.", |
Heschi Kreinick | a1a1cbe | 2020-12-01 12:19:44 -0500 | [diff] [blame] | 874 | }, |
Heschi Kreinick | a1a1cbe | 2020-12-01 12:19:44 -0500 | [diff] [blame] | 875 | }, |
Rebecca Stambler | fbbba25 | 2020-12-25 15:10:04 -0500 | [diff] [blame] | 876 | Analyzers: []*AnalyzerJSON{ |
| 877 | { |
| 878 | Name: "asmdecl", |
| 879 | Doc: "report mismatches between assembly files and Go declarations", |
Alan Donovan | e5f7ae1 | 2023-03-15 14:36:36 -0400 | [diff] [blame] | 880 | URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/asmdecl", |
Rebecca Stambler | fbbba25 | 2020-12-25 15:10:04 -0500 | [diff] [blame] | 881 | 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 Donovan | e5f7ae1 | 2023-03-15 14:36:36 -0400 | [diff] [blame] | 886 | URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/assign", |
Rebecca Stambler | fbbba25 | 2020-12-25 15:10:04 -0500 | [diff] [blame] | 887 | Default: true, |
| 888 | }, |
| 889 | { |
| 890 | Name: "atomic", |
| 891 | Doc: "check for common mistakes using the sync/atomic package\n\nThe atomic checker looks for assignment statements of the form:\n\n\tx = atomic.AddUint64(&x, 1)\n\nwhich are not atomic.", |
Alan Donovan | e5f7ae1 | 2023-03-15 14:36:36 -0400 | [diff] [blame] | 892 | URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/atomic", |
Rebecca Stambler | fbbba25 | 2020-12-25 15:10:04 -0500 | [diff] [blame] | 893 | Default: true, |
| 894 | }, |
| 895 | { |
| 896 | Name: "atomicalign", |
| 897 | Doc: "check for non-64-bits-aligned arguments to sync/atomic functions", |
Alan Donovan | e5f7ae1 | 2023-03-15 14:36:36 -0400 | [diff] [blame] | 898 | URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/atomicalign", |
Rebecca Stambler | fbbba25 | 2020-12-25 15:10:04 -0500 | [diff] [blame] | 899 | Default: true, |
| 900 | }, |
| 901 | { |
| 902 | Name: "bools", |
| 903 | Doc: "check for common mistakes involving boolean operators", |
Alan Donovan | e5f7ae1 | 2023-03-15 14:36:36 -0400 | [diff] [blame] | 904 | URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/bools", |
Rebecca Stambler | fbbba25 | 2020-12-25 15:10:04 -0500 | [diff] [blame] | 905 | Default: true, |
| 906 | }, |
| 907 | { |
| 908 | Name: "buildtag", |
Russ Cox | bcc7794 | 2023-01-14 17:13:29 -0500 | [diff] [blame] | 909 | Doc: "check //go:build and // +build directives", |
Alan Donovan | e5f7ae1 | 2023-03-15 14:36:36 -0400 | [diff] [blame] | 910 | URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/buildtag", |
Rebecca Stambler | fbbba25 | 2020-12-25 15:10:04 -0500 | [diff] [blame] | 911 | 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 Donovan | e5f7ae1 | 2023-03-15 14:36:36 -0400 | [diff] [blame] | 916 | URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/cgocall", |
Rebecca Stambler | fbbba25 | 2020-12-25 15:10:04 -0500 | [diff] [blame] | 917 | 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 Donovan | e5f7ae1 | 2023-03-15 14:36:36 -0400 | [diff] [blame] | 922 | URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/composites", |
Rebecca Stambler | fbbba25 | 2020-12-25 15:10:04 -0500 | [diff] [blame] | 923 | 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 Donovan | e5f7ae1 | 2023-03-15 14:36:36 -0400 | [diff] [blame] | 928 | URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/copylocks", |
Rebecca Stambler | fbbba25 | 2020-12-25 15:10:04 -0500 | [diff] [blame] | 929 | 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 Donovan | e5f7ae1 | 2023-03-15 14:36:36 -0400 | [diff] [blame] | 934 | URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/deepequalerrors", |
Rebecca Stambler | fbbba25 | 2020-12-25 15:10:04 -0500 | [diff] [blame] | 935 | Default: true, |
| 936 | }, |
| 937 | { |
Russ Cox | bcc7794 | 2023-01-14 17:13:29 -0500 | [diff] [blame] | 938 | 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 Donovan | e5f7ae1 | 2023-03-15 14:36:36 -0400 | [diff] [blame] | 940 | URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/directive", |
Russ Cox | bcc7794 | 2023-01-14 17:13:29 -0500 | [diff] [blame] | 941 | Default: true, |
| 942 | }, |
| 943 | { |
Nooras Saba | 28c754d | 2022-04-18 18:17:15 -0400 | [diff] [blame] | 944 | 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 Stambler | fbbba25 | 2020-12-25 15:10:04 -0500 | [diff] [blame] | 949 | 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 Donovan | e5f7ae1 | 2023-03-15 14:36:36 -0400 | [diff] [blame] | 951 | URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/errorsas", |
Rebecca Stambler | fbbba25 | 2020-12-25 15:10:04 -0500 | [diff] [blame] | 952 | Default: true, |
| 953 | }, |
| 954 | { |
Jonathan Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 955 | Name: "fieldalignment", |
Alan Donovan | b84d509 | 2022-06-29 13:02:25 -0400 | [diff] [blame] | 956 | 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 Donovan | e5f7ae1 | 2023-03-15 14:36:36 -0400 | [diff] [blame] | 957 | URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/fieldalignment", |
Rebecca Stambler | fbbba25 | 2020-12-25 15:10:04 -0500 | [diff] [blame] | 958 | }, |
| 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 Donovan | e5f7ae1 | 2023-03-15 14:36:36 -0400 | [diff] [blame] | 962 | URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/httpresponse", |
Rebecca Stambler | fbbba25 | 2020-12-25 15:10:04 -0500 | [diff] [blame] | 963 | Default: true, |
| 964 | }, |
| 965 | { |
| 966 | Name: "ifaceassert", |
Alan Donovan | 255eeeb | 2023-03-09 10:17:50 -0500 | [diff] [blame] | 967 | 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 Donovan | e5f7ae1 | 2023-03-15 14:36:36 -0400 | [diff] [blame] | 968 | URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/ifaceassert", |
Rebecca Stambler | fbbba25 | 2020-12-25 15:10:04 -0500 | [diff] [blame] | 969 | Default: true, |
| 970 | }, |
| 971 | { |
| 972 | Name: "loopclosure", |
Alan Donovan | 255eeeb | 2023-03-09 10:17:50 -0500 | [diff] [blame] | 973 | 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 Donovan | e5f7ae1 | 2023-03-15 14:36:36 -0400 | [diff] [blame] | 974 | URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/loopclosure", |
Rebecca Stambler | fbbba25 | 2020-12-25 15:10:04 -0500 | [diff] [blame] | 975 | 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 Donovan | e5f7ae1 | 2023-03-15 14:36:36 -0400 | [diff] [blame] | 980 | URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/lostcancel", |
Rebecca Stambler | fbbba25 | 2020-12-25 15:10:04 -0500 | [diff] [blame] | 981 | 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 Donovan | e5f7ae1 | 2023-03-15 14:36:36 -0400 | [diff] [blame] | 986 | URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/nilfunc", |
Rebecca Stambler | fbbba25 | 2020-12-25 15:10:04 -0500 | [diff] [blame] | 987 | Default: true, |
| 988 | }, |
| 989 | { |
Jonathan Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 990 | Name: "nilness", |
Alan Donovan | 255eeeb | 2023-03-09 10:17:50 -0500 | [diff] [blame] | 991 | 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 Donovan | e5f7ae1 | 2023-03-15 14:36:36 -0400 | [diff] [blame] | 992 | URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/nilness", |
Ainar Garipov | 1e524e2 | 2021-03-08 12:00:26 +0300 | [diff] [blame] | 993 | }, |
| 994 | { |
Rebecca Stambler | fbbba25 | 2020-12-25 15:10:04 -0500 | [diff] [blame] | 995 | Name: "printf", |
Alan Donovan | cbe6614 | 2023-03-22 09:44:16 -0400 | [diff] [blame] | 996 | 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 Donovan | e5f7ae1 | 2023-03-15 14:36:36 -0400 | [diff] [blame] | 997 | URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/printf", |
Rebecca Stambler | fbbba25 | 2020-12-25 15:10:04 -0500 | [diff] [blame] | 998 | Default: true, |
| 999 | }, |
| 1000 | { |
Jonathan Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 1001 | Name: "shadow", |
Alan Donovan | 255eeeb | 2023-03-09 10:17:50 -0500 | [diff] [blame] | 1002 | 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 Donovan | e5f7ae1 | 2023-03-15 14:36:36 -0400 | [diff] [blame] | 1003 | URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/shadow", |
Rebecca Stambler | fbbba25 | 2020-12-25 15:10:04 -0500 | [diff] [blame] | 1004 | }, |
| 1005 | { |
| 1006 | Name: "shift", |
| 1007 | Doc: "check for shifts that equal or exceed the width of the integer", |
Alan Donovan | e5f7ae1 | 2023-03-15 14:36:36 -0400 | [diff] [blame] | 1008 | URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/shift", |
Rebecca Stambler | fbbba25 | 2020-12-25 15:10:04 -0500 | [diff] [blame] | 1009 | 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 Donovan | e5f7ae1 | 2023-03-15 14:36:36 -0400 | [diff] [blame] | 1029 | URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/sortslice", |
Rebecca Stambler | fbbba25 | 2020-12-25 15:10:04 -0500 | [diff] [blame] | 1030 | Default: true, |
| 1031 | }, |
| 1032 | { |
| 1033 | Name: "stdmethods", |
Alan Donovan | 255eeeb | 2023-03-09 10:17:50 -0500 | [diff] [blame] | 1034 | 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 Donovan | e5f7ae1 | 2023-03-15 14:36:36 -0400 | [diff] [blame] | 1035 | URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/stdmethods", |
Rebecca Stambler | fbbba25 | 2020-12-25 15:10:04 -0500 | [diff] [blame] | 1036 | Default: true, |
| 1037 | }, |
| 1038 | { |
| 1039 | Name: "stringintconv", |
Alan Donovan | 255eeeb | 2023-03-09 10:17:50 -0500 | [diff] [blame] | 1040 | 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 Donovan | e5f7ae1 | 2023-03-15 14:36:36 -0400 | [diff] [blame] | 1041 | URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/stringintconv", |
Rebecca Stambler | fbbba25 | 2020-12-25 15:10:04 -0500 | [diff] [blame] | 1042 | 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 Donovan | e5f7ae1 | 2023-03-15 14:36:36 -0400 | [diff] [blame] | 1047 | URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/structtag", |
Rebecca Stambler | fbbba25 | 2020-12-25 15:10:04 -0500 | [diff] [blame] | 1048 | Default: true, |
| 1049 | }, |
| 1050 | { |
| 1051 | Name: "testinggoroutine", |
Alan Donovan | 255eeeb | 2023-03-09 10:17:50 -0500 | [diff] [blame] | 1052 | 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 Donovan | e5f7ae1 | 2023-03-15 14:36:36 -0400 | [diff] [blame] | 1053 | URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/testinggoroutine", |
Rebecca Stambler | fbbba25 | 2020-12-25 15:10:04 -0500 | [diff] [blame] | 1054 | Default: true, |
| 1055 | }, |
| 1056 | { |
| 1057 | Name: "tests", |
Nooras Saba | f4e613e | 2023-02-24 18:00:43 -0500 | [diff] [blame] | 1058 | 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 Donovan | e5f7ae1 | 2023-03-15 14:36:36 -0400 | [diff] [blame] | 1059 | URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/tests", |
Rebecca Stambler | fbbba25 | 2020-12-25 15:10:04 -0500 | [diff] [blame] | 1060 | Default: true, |
| 1061 | }, |
| 1062 | { |
Erik Dubbelboer | 371fc67 | 2022-07-29 19:27:57 +0000 | [diff] [blame] | 1063 | Name: "timeformat", |
Alan Donovan | 255eeeb | 2023-03-09 10:17:50 -0500 | [diff] [blame] | 1064 | 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 Donovan | e5f7ae1 | 2023-03-15 14:36:36 -0400 | [diff] [blame] | 1065 | URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/timeformat", |
Erik Dubbelboer | 371fc67 | 2022-07-29 19:27:57 +0000 | [diff] [blame] | 1066 | Default: true, |
| 1067 | }, |
| 1068 | { |
Rebecca Stambler | fbbba25 | 2020-12-25 15:10:04 -0500 | [diff] [blame] | 1069 | 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 Donovan | e5f7ae1 | 2023-03-15 14:36:36 -0400 | [diff] [blame] | 1071 | URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/unmarshal", |
Rebecca Stambler | fbbba25 | 2020-12-25 15:10:04 -0500 | [diff] [blame] | 1072 | 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 Donovan | e5f7ae1 | 2023-03-15 14:36:36 -0400 | [diff] [blame] | 1077 | URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/unreachable", |
Rebecca Stambler | fbbba25 | 2020-12-25 15:10:04 -0500 | [diff] [blame] | 1078 | Default: true, |
| 1079 | }, |
| 1080 | { |
| 1081 | Name: "unsafeptr", |
Alan Donovan | 6d1dd12 | 2023-04-27 14:49:05 -0400 | [diff] [blame] | 1082 | 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 Donovan | e5f7ae1 | 2023-03-15 14:36:36 -0400 | [diff] [blame] | 1083 | URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/unsafeptr", |
Rebecca Stambler | fbbba25 | 2020-12-25 15:10:04 -0500 | [diff] [blame] | 1084 | Default: true, |
| 1085 | }, |
| 1086 | { |
Jonathan Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 1087 | 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 Stambler | fbbba25 | 2020-12-25 15:10:04 -0500 | [diff] [blame] | 1089 | }, |
| 1090 | { |
| 1091 | Name: "unusedresult", |
Alan Donovan | 6d1dd12 | 2023-04-27 14:49:05 -0400 | [diff] [blame] | 1092 | 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 Donovan | e5f7ae1 | 2023-03-15 14:36:36 -0400 | [diff] [blame] | 1093 | URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/unusedresult", |
Rebecca Stambler | fbbba25 | 2020-12-25 15:10:04 -0500 | [diff] [blame] | 1094 | Default: true, |
| 1095 | }, |
| 1096 | { |
Jonathan Amsterdam | 8d38310 | 2021-12-13 10:33:51 -0500 | [diff] [blame] | 1097 | Name: "unusedwrite", |
Alan Donovan | 255eeeb | 2023-03-09 10:17:50 -0500 | [diff] [blame] | 1098 | 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 Donovan | e5f7ae1 | 2023-03-15 14:36:36 -0400 | [diff] [blame] | 1099 | URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/unusedwrite", |
Ainar Garipov | b8d1a33 | 2021-02-23 12:42:06 +0300 | [diff] [blame] | 1100 | }, |
| 1101 | { |
Robert Findley | 258e473 | 2022-02-22 10:07:30 -0500 | [diff] [blame] | 1102 | Name: "useany", |
| 1103 | Doc: "check for constraints that could be simplified to \"any\"", |
Robert Findley | 2847958 | 2021-09-22 11:06:05 -0400 | [diff] [blame] | 1104 | }, |
| 1105 | { |
Rebecca Stambler | fbbba25 | 2020-12-25 15:10:04 -0500 | [diff] [blame] | 1106 | Name: "fillreturns", |
Robert Findley | f64c0f4 | 2021-11-29 23:01:21 -0500 | [diff] [blame] | 1107 | 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 Stambler | fbbba25 | 2020-12-25 15:10:04 -0500 | [diff] [blame] | 1108 | 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 Cox | fddb0d5 | 2022-01-18 13:51:12 -0500 | [diff] [blame] | 1117 | 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 Stambler | fbbba25 | 2020-12-25 15:10:04 -0500 | [diff] [blame] | 1118 | Default: true, |
| 1119 | }, |
| 1120 | { |
| 1121 | Name: "undeclaredname", |
Rebecca Stambler | 7898fe6 | 2021-09-21 17:59:25 -0400 | [diff] [blame] | 1122 | 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 Stambler | fbbba25 | 2020-12-25 15:10:04 -0500 | [diff] [blame] | 1123 | Default: true, |
| 1124 | }, |
| 1125 | { |
Francesco Renzi | 1a4e02f | 2022-03-23 01:19:43 +0100 | [diff] [blame] | 1126 | Name: "unusedvariable", |
| 1127 | Doc: "check for unused variables\n\nThe unusedvariable analyzer suggests fixes for unused variables errors.\n", |
| 1128 | }, |
| 1129 | { |
Rebecca Stambler | fbbba25 | 2020-12-25 15:10:04 -0500 | [diff] [blame] | 1130 | 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 Sulaiman | 70c3ea2 | 2021-09-16 17:26:44 -0400 | [diff] [blame] | 1134 | { |
Robert Findley | c64bb76 | 2023-02-28 15:08:31 -0500 | [diff] [blame] | 1135 | 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 Sulaiman | 70c3ea2 | 2021-09-16 17:26:44 -0400 | [diff] [blame] | 1140 | 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 Stambler | fbbba25 | 2020-12-25 15:10:04 -0500 | [diff] [blame] | 1144 | }, |
Suzy Mueller | 871637b | 2022-06-13 19:25:46 -0400 | [diff] [blame] | 1145 | Hints: []*HintJSON{ |
| 1146 | { |
Jamal Carvalho | 60ca636 | 2022-06-24 17:11:38 +0000 | [diff] [blame] | 1147 | Name: "assignVariableTypes", |
Suzy Mueller | c83f42d | 2022-07-26 12:16:16 -0400 | [diff] [blame] | 1148 | Doc: "Enable/disable inlay hints for variable types in assign statements:\n```go\n\ti/* int*/, j/* int*/ := 0, len(r)-1\n```", |
Suzy Mueller | 871637b | 2022-06-13 19:25:46 -0400 | [diff] [blame] | 1149 | }, |
| 1150 | { |
Jamal Carvalho | 60ca636 | 2022-06-24 17:11:38 +0000 | [diff] [blame] | 1151 | Name: "compositeLiteralFields", |
Suzy Mueller | c83f42d | 2022-07-26 12:16:16 -0400 | [diff] [blame] | 1152 | Doc: "Enable/disable inlay hints for composite literal field names:\n```go\n\t{/*in: */\"Hello, world\", /*want: */\"dlrow ,olleH\"}\n```", |
Suzy Mueller | 871637b | 2022-06-13 19:25:46 -0400 | [diff] [blame] | 1153 | }, |
| 1154 | { |
Jamal Carvalho | 60ca636 | 2022-06-24 17:11:38 +0000 | [diff] [blame] | 1155 | Name: "compositeLiteralTypes", |
Suzy Mueller | c83f42d | 2022-07-26 12:16:16 -0400 | [diff] [blame] | 1156 | 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 Mueller | 871637b | 2022-06-13 19:25:46 -0400 | [diff] [blame] | 1157 | }, |
| 1158 | { |
Jamal Carvalho | 60ca636 | 2022-06-24 17:11:38 +0000 | [diff] [blame] | 1159 | Name: "constantValues", |
Suzy Mueller | c83f42d | 2022-07-26 12:16:16 -0400 | [diff] [blame] | 1160 | 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 Mueller | 871637b | 2022-06-13 19:25:46 -0400 | [diff] [blame] | 1161 | }, |
| 1162 | { |
Jamal Carvalho | 60ca636 | 2022-06-24 17:11:38 +0000 | [diff] [blame] | 1163 | Name: "functionTypeParameters", |
Suzy Mueller | c83f42d | 2022-07-26 12:16:16 -0400 | [diff] [blame] | 1164 | Doc: "Enable/disable inlay hints for implicit type parameters on generic functions:\n```go\n\tmyFoo/*[int, string]*/(1, \"hello\")\n```", |
Suzy Mueller | 871637b | 2022-06-13 19:25:46 -0400 | [diff] [blame] | 1165 | }, |
| 1166 | { |
Jamal Carvalho | 60ca636 | 2022-06-24 17:11:38 +0000 | [diff] [blame] | 1167 | Name: "parameterNames", |
Suzy Mueller | c83f42d | 2022-07-26 12:16:16 -0400 | [diff] [blame] | 1168 | Doc: "Enable/disable inlay hints for parameter names:\n```go\n\tparseInt(/* str: */ \"123\", /* radix: */ 8)\n```", |
Suzy Mueller | 871637b | 2022-06-13 19:25:46 -0400 | [diff] [blame] | 1169 | }, |
| 1170 | { |
Jamal Carvalho | 60ca636 | 2022-06-24 17:11:38 +0000 | [diff] [blame] | 1171 | Name: "rangeVariableTypes", |
Suzy Mueller | c83f42d | 2022-07-26 12:16:16 -0400 | [diff] [blame] | 1172 | 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 Mueller | 871637b | 2022-06-13 19:25:46 -0400 | [diff] [blame] | 1173 | }, |
| 1174 | }, |
Heschi Kreinick | a1a1cbe | 2020-12-01 12:19:44 -0500 | [diff] [blame] | 1175 | } |