gopls/doc: use improved code generator for API doc
Use github.com/jba/printsrc in place of github.com/sanity-io/litter to
generate the Go code with API documentation. It is smart enough
to elide type names, making the "massive hack" of deleting them
unnecessary. It also omits zero values from the output.
Change-Id: Ic1bb937b9a3695e6da6db72b74c6049be1c5b80d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/370840
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
diff --git a/internal/lsp/source/api_json.go b/internal/lsp/source/api_json.go
index 5c4e51d..95a1aff 100755
--- a/internal/lsp/source/api_json.go
+++ b/internal/lsp/source/api_json.go
@@ -6,333 +6,184 @@
Options: map[string][]*OptionJSON{
"User": {
{
- Name: "buildFlags",
- Type: "[]string",
- 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",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
- EnumValues: nil,
- Default: "[]",
- Status: "",
- Hierarchy: "build",
+ Name: "buildFlags",
+ Type: "[]string",
+ 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",
+ Default: "[]",
+ Hierarchy: "build",
},
{
- Name: "env",
- Type: "map[string]string",
- Doc: "env adds environment variables to external commands run by `gopls`, most notably `go list`.\n",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
- EnumValues: nil,
- Default: "{}",
- Status: "",
- Hierarchy: "build",
+ Name: "env",
+ Type: "map[string]string",
+ Doc: "env adds environment variables to external commands run by `gopls`, most notably `go list`.\n",
+ Default: "{}",
+ Hierarchy: "build",
},
{
- Name: "directoryFilters",
- Type: "[]string",
- Doc: "directoryFilters can be used to exclude unwanted directories from the\nworkspace. By default, all directories are included. Filters are an\noperator, `+` to include and `-` to exclude, followed by a path prefix\nrelative to the workspace folder. They are evaluated in order, and\nthe last filter that applies to a path controls whether it is included.\nThe path prefix can be empty, so an initial `-` excludes everything.\n\nExamples:\n\nExclude node_modules: `-node_modules`\n\nInclude only project_a: `-` (exclude everything), `+project_a`\n\nInclude only project_a, but not node_modules inside it: `-`, `+project_a`, `-project_a/node_modules`\n",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
- EnumValues: nil,
- Default: "[\"-node_modules\"]",
- Status: "",
- Hierarchy: "build",
+ Name: "directoryFilters",
+ Type: "[]string",
+ Doc: "directoryFilters can be used to exclude unwanted directories from the\nworkspace. By default, all directories are included. Filters are an\noperator, `+` to include and `-` to exclude, followed by a path prefix\nrelative to the workspace folder. They are evaluated in order, and\nthe last filter that applies to a path controls whether it is included.\nThe path prefix can be empty, so an initial `-` excludes everything.\n\nExamples:\n\nExclude node_modules: `-node_modules`\n\nInclude only project_a: `-` (exclude everything), `+project_a`\n\nInclude only project_a, but not node_modules inside it: `-`, `+project_a`, `-project_a/node_modules`\n",
+ Default: "[\"-node_modules\"]",
+ Hierarchy: "build",
},
{
- Name: "templateExtensions",
- Type: "[]string",
- 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",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
- EnumValues: nil,
- Default: "[\"tmpl\",\"gotmpl\"]",
- Status: "",
- Hierarchy: "build",
+ Name: "templateExtensions",
+ Type: "[]string",
+ 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",
+ Default: "[\"tmpl\",\"gotmpl\"]",
+ Hierarchy: "build",
},
{
Name: "memoryMode",
Type: "enum",
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",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
EnumValues: []EnumValue{
{
Value: "\"DegradeClosed\"",
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",
},
- {
- Value: "\"Normal\"",
- Doc: "",
- },
+ {Value: "\"Normal\""},
},
Default: "\"Normal\"",
Status: "experimental",
Hierarchy: "build",
},
{
- Name: "expandWorkspaceToModule",
- Type: "bool",
- 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",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
- EnumValues: nil,
- Default: "true",
- Status: "experimental",
- Hierarchy: "build",
+ Name: "expandWorkspaceToModule",
+ Type: "bool",
+ 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",
+ Default: "true",
+ Status: "experimental",
+ Hierarchy: "build",
},
{
- Name: "experimentalWorkspaceModule",
- Type: "bool",
- Doc: "experimentalWorkspaceModule opts a user into the experimental support\nfor multi-module workspaces.\n",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
- EnumValues: nil,
- Default: "false",
- Status: "experimental",
- Hierarchy: "build",
+ Name: "experimentalWorkspaceModule",
+ Type: "bool",
+ Doc: "experimentalWorkspaceModule opts a user into the experimental support\nfor multi-module workspaces.\n",
+ Default: "false",
+ Status: "experimental",
+ Hierarchy: "build",
},
{
- Name: "experimentalPackageCacheKey",
- Type: "bool",
- Doc: "experimentalPackageCacheKey controls whether to use a coarser cache key\nfor package type information to increase cache hits. This setting removes\nthe user's environment, build flags, and working directory from the cache\nkey, which should be a safe change as all relevant inputs into the type\nchecking pass are already hashed into the key. This is temporarily guarded\nby an experiment because caching behavior is subtle and difficult to\ncomprehensively test.\n",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
- EnumValues: nil,
- Default: "true",
- Status: "experimental",
- Hierarchy: "build",
+ Name: "experimentalPackageCacheKey",
+ Type: "bool",
+ Doc: "experimentalPackageCacheKey controls whether to use a coarser cache key\nfor package type information to increase cache hits. This setting removes\nthe user's environment, build flags, and working directory from the cache\nkey, which should be a safe change as all relevant inputs into the type\nchecking pass are already hashed into the key. This is temporarily guarded\nby an experiment because caching behavior is subtle and difficult to\ncomprehensively test.\n",
+ Default: "true",
+ Status: "experimental",
+ Hierarchy: "build",
},
{
- Name: "allowModfileModifications",
- Type: "bool",
- Doc: "allowModfileModifications disables -mod=readonly, allowing imports from\nout-of-scope modules. This option will eventually be removed.\n",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
- EnumValues: nil,
- Default: "false",
- Status: "experimental",
- Hierarchy: "build",
+ Name: "allowModfileModifications",
+ Type: "bool",
+ Doc: "allowModfileModifications disables -mod=readonly, allowing imports from\nout-of-scope modules. This option will eventually be removed.\n",
+ Default: "false",
+ Status: "experimental",
+ Hierarchy: "build",
},
{
- Name: "allowImplicitNetworkAccess",
- Type: "bool",
- Doc: "allowImplicitNetworkAccess disables GOPROXY=off, allowing implicit module\ndownloads rather than requiring user action. This option will eventually\nbe removed.\n",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
- EnumValues: nil,
- Default: "false",
- Status: "experimental",
- Hierarchy: "build",
+ Name: "allowImplicitNetworkAccess",
+ Type: "bool",
+ Doc: "allowImplicitNetworkAccess disables GOPROXY=off, allowing implicit module\ndownloads rather than requiring user action. This option will eventually\nbe removed.\n",
+ Default: "false",
+ Status: "experimental",
+ Hierarchy: "build",
},
{
- Name: "experimentalUseInvalidMetadata",
- Type: "bool",
- Doc: "experimentalUseInvalidMetadata enables gopls to fall back on outdated\npackage metadata to provide editor features if the go command fails to\nload packages for some reason (like an invalid go.mod file). This will\neventually be the default behavior, and this setting will be removed.\n",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
- EnumValues: nil,
- Default: "false",
- Status: "experimental",
- Hierarchy: "build",
+ Name: "experimentalUseInvalidMetadata",
+ Type: "bool",
+ Doc: "experimentalUseInvalidMetadata enables gopls to fall back on outdated\npackage metadata to provide editor features if the go command fails to\nload packages for some reason (like an invalid go.mod file). This will\neventually be the default behavior, and this setting will be removed.\n",
+ Default: "false",
+ Status: "experimental",
+ Hierarchy: "build",
},
{
Name: "hoverKind",
Type: "enum",
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",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
EnumValues: []EnumValue{
- {
- Value: "\"FullDocumentation\"",
- Doc: "",
- },
- {
- Value: "\"NoDocumentation\"",
- Doc: "",
- },
- {
- Value: "\"SingleLine\"",
- Doc: "",
- },
+ {Value: "\"FullDocumentation\""},
+ {Value: "\"NoDocumentation\""},
+ {Value: "\"SingleLine\""},
{
Value: "\"Structured\"",
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",
},
- {
- Value: "\"SynopsisDocumentation\"",
- Doc: "",
- },
+ {Value: "\"SynopsisDocumentation\""},
},
Default: "\"FullDocumentation\"",
- Status: "",
Hierarchy: "ui.documentation",
},
{
- Name: "linkTarget",
- Type: "string",
- 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",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
- EnumValues: nil,
- Default: "\"pkg.go.dev\"",
- Status: "",
- Hierarchy: "ui.documentation",
+ Name: "linkTarget",
+ Type: "string",
+ 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",
+ Default: "\"pkg.go.dev\"",
+ Hierarchy: "ui.documentation",
},
{
- Name: "linksInHover",
- Type: "bool",
- Doc: "linksInHover toggles the presence of links to documentation in hover.\n",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
- EnumValues: nil,
- Default: "true",
- Status: "",
- Hierarchy: "ui.documentation",
+ Name: "linksInHover",
+ Type: "bool",
+ Doc: "linksInHover toggles the presence of links to documentation in hover.\n",
+ Default: "true",
+ Hierarchy: "ui.documentation",
},
{
- Name: "usePlaceholders",
- Type: "bool",
- Doc: "placeholders enables placeholders for function parameters or struct\nfields in completion responses.\n",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
- EnumValues: nil,
- Default: "false",
- Status: "",
- Hierarchy: "ui.completion",
+ Name: "usePlaceholders",
+ Type: "bool",
+ Doc: "placeholders enables placeholders for function parameters or struct\nfields in completion responses.\n",
+ Default: "false",
+ Hierarchy: "ui.completion",
},
{
- Name: "completionBudget",
- Type: "time.Duration",
- 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",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
- EnumValues: nil,
- Default: "\"100ms\"",
- Status: "debug",
- Hierarchy: "ui.completion",
+ Name: "completionBudget",
+ Type: "time.Duration",
+ 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",
+ Default: "\"100ms\"",
+ Status: "debug",
+ Hierarchy: "ui.completion",
},
{
Name: "matcher",
Type: "enum",
Doc: "matcher sets the algorithm that is used when calculating completion\ncandidates.\n",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
EnumValues: []EnumValue{
- {
- Value: "\"CaseInsensitive\"",
- Doc: "",
- },
- {
- Value: "\"CaseSensitive\"",
- Doc: "",
- },
- {
- Value: "\"Fuzzy\"",
- Doc: "",
- },
+ {Value: "\"CaseInsensitive\""},
+ {Value: "\"CaseSensitive\""},
+ {Value: "\"Fuzzy\""},
},
Default: "\"Fuzzy\"",
Status: "advanced",
Hierarchy: "ui.completion",
},
{
- Name: "experimentalPostfixCompletions",
- Type: "bool",
- Doc: "experimentalPostfixCompletions enables artifical method snippets\nsuch as \"someSlice.sort!\".\n",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
- EnumValues: nil,
- Default: "true",
- Status: "experimental",
- Hierarchy: "ui.completion",
+ Name: "experimentalPostfixCompletions",
+ Type: "bool",
+ Doc: "experimentalPostfixCompletions enables artifical method snippets\nsuch as \"someSlice.sort!\".\n",
+ Default: "true",
+ Status: "experimental",
+ Hierarchy: "ui.completion",
},
{
Name: "importShortcut",
Type: "enum",
Doc: "importShortcut specifies whether import statements should link to\ndocumentation or go to definitions.\n",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
EnumValues: []EnumValue{
- {
- Value: "\"Both\"",
- Doc: "",
- },
- {
- Value: "\"Definition\"",
- Doc: "",
- },
- {
- Value: "\"Link\"",
- Doc: "",
- },
+ {Value: "\"Both\""},
+ {Value: "\"Definition\""},
+ {Value: "\"Link\""},
},
Default: "\"Both\"",
- Status: "",
Hierarchy: "ui.navigation",
},
{
Name: "symbolMatcher",
Type: "enum",
Doc: "symbolMatcher sets the algorithm that is used when finding workspace symbols.\n",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
EnumValues: []EnumValue{
- {
- Value: "\"CaseInsensitive\"",
- Doc: "",
- },
- {
- Value: "\"CaseSensitive\"",
- Doc: "",
- },
- {
- Value: "\"FastFuzzy\"",
- Doc: "",
- },
- {
- Value: "\"Fuzzy\"",
- Doc: "",
- },
+ {Value: "\"CaseInsensitive\""},
+ {Value: "\"CaseSensitive\""},
+ {Value: "\"FastFuzzy\""},
+ {Value: "\"Fuzzy\""},
},
Default: "\"Fuzzy\"",
Status: "advanced",
@@ -342,10 +193,6 @@
Name: "symbolStyle",
Type: "enum",
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",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
EnumValues: []EnumValue{
{
Value: "\"Dynamic\"",
@@ -588,23 +435,16 @@
},
},
},
- EnumValues: nil,
- Default: "{}",
- Status: "",
- Hierarchy: "ui.diagnostic",
+ Default: "{}",
+ Hierarchy: "ui.diagnostic",
},
{
- Name: "staticcheck",
- Type: "bool",
- Doc: "staticcheck enables additional analyses from staticcheck.io.\n",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
- EnumValues: nil,
- Default: "false",
- Status: "experimental",
- Hierarchy: "ui.diagnostic",
+ Name: "staticcheck",
+ Type: "bool",
+ Doc: "staticcheck enables additional analyses from staticcheck.io.\n",
+ Default: "false",
+ Status: "experimental",
+ Hierarchy: "ui.diagnostic",
},
{
Name: "annotations",
@@ -635,36 +475,25 @@
},
},
},
- EnumValues: nil,
- Default: "{\"bounds\":true,\"escape\":true,\"inline\":true,\"nil\":true}",
- Status: "experimental",
- Hierarchy: "ui.diagnostic",
+ Default: "{\"bounds\":true,\"escape\":true,\"inline\":true,\"nil\":true}",
+ Status: "experimental",
+ Hierarchy: "ui.diagnostic",
},
{
- Name: "diagnosticsDelay",
- Type: "time.Duration",
- 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",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
- EnumValues: nil,
- Default: "\"250ms\"",
- Status: "advanced",
- Hierarchy: "ui.diagnostic",
+ Name: "diagnosticsDelay",
+ Type: "time.Duration",
+ 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",
+ Default: "\"250ms\"",
+ Status: "advanced",
+ Hierarchy: "ui.diagnostic",
},
{
- Name: "experimentalWatchedFileDelay",
- Type: "time.Duration",
- Doc: "experimentalWatchedFileDelay controls the amount of time that gopls waits\nfor additional workspace/didChangeWatchedFiles notifications to arrive,\nbefore processing all such notifications in a single batch. This is\nintended for use by LSP clients that don't support their own batching of\nfile system notifications.\n\nThis option must be set to a valid duration string, for example `\"100ms\"`.\n",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
- EnumValues: nil,
- Default: "\"0s\"",
- Status: "experimental",
- Hierarchy: "ui.diagnostic",
+ Name: "experimentalWatchedFileDelay",
+ Type: "time.Duration",
+ Doc: "experimentalWatchedFileDelay controls the amount of time that gopls waits\nfor additional workspace/didChangeWatchedFiles notifications to arrive,\nbefore processing all such notifications in a single batch. This is\nintended for use by LSP clients that don't support their own batching of\nfile system notifications.\n\nThis option must be set to a valid duration string, for example `\"100ms\"`.\n",
+ Default: "\"0s\"",
+ Status: "experimental",
+ Hierarchy: "ui.diagnostic",
},
{
Name: "codelenses",
@@ -710,121 +539,88 @@
},
},
},
- EnumValues: nil,
- Default: "{\"gc_details\":false,\"generate\":true,\"regenerate_cgo\":true,\"tidy\":true,\"upgrade_dependency\":true,\"vendor\":true}",
- Status: "",
- Hierarchy: "ui",
+ Default: "{\"gc_details\":false,\"generate\":true,\"regenerate_cgo\":true,\"tidy\":true,\"upgrade_dependency\":true,\"vendor\":true}",
+ Hierarchy: "ui",
},
{
- Name: "semanticTokens",
- Type: "bool",
- Doc: "semanticTokens controls whether the LSP server will send\nsemantic tokens to the client.\n",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
- EnumValues: nil,
- Default: "false",
- Status: "experimental",
- Hierarchy: "ui",
+ Name: "semanticTokens",
+ Type: "bool",
+ Doc: "semanticTokens controls whether the LSP server will send\nsemantic tokens to the client.\n",
+ Default: "false",
+ Status: "experimental",
+ Hierarchy: "ui",
},
{
- Name: "local",
- Type: "string",
- 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",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
- EnumValues: nil,
- Default: "\"\"",
- Status: "",
- Hierarchy: "formatting",
+ Name: "local",
+ Type: "string",
+ 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",
+ Default: "\"\"",
+ Hierarchy: "formatting",
},
{
- Name: "gofumpt",
- Type: "bool",
- Doc: "gofumpt indicates if we should run gofumpt formatting.\n",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
- EnumValues: nil,
- Default: "false",
- Status: "",
- Hierarchy: "formatting",
+ Name: "gofumpt",
+ Type: "bool",
+ Doc: "gofumpt indicates if we should run gofumpt formatting.\n",
+ Default: "false",
+ Hierarchy: "formatting",
},
{
- Name: "verboseOutput",
- Type: "bool",
- Doc: "verboseOutput enables additional debug logging.\n",
- EnumKeys: EnumKeys{
- ValueType: "",
- Keys: nil,
- },
- EnumValues: nil,
- Default: "false",
- Status: "debug",
- Hierarchy: "",
+ Name: "verboseOutput",
+ Type: "bool",
+ Doc: "verboseOutput enables additional debug logging.\n",
+ Default: "false",
+ Status: "debug",
},
},
},
Commands: []*CommandJSON{
{
- Command: "gopls.add_dependency",
- Title: "Add a dependency",
- Doc: "Adds a dependency to the go.mod file for a module.",
- 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}",
- ResultDoc: "",
+ Command: "gopls.add_dependency",
+ Title: "Add a dependency",
+ Doc: "Adds a dependency to the go.mod file for a module.",
+ 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}",
},
{
- Command: "gopls.add_import",
- Title: "Add an import",
- 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.",
- 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}",
- ResultDoc: "",
+ Command: "gopls.add_import",
+ Title: "Add an import",
+ 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.",
+ 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}",
},
{
- Command: "gopls.apply_fix",
- Title: "Apply a fix",
- Doc: "Applies a fix to a region of source code.",
- 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}",
- ResultDoc: "",
+ Command: "gopls.apply_fix",
+ Title: "Apply a fix",
+ Doc: "Applies a fix to a region of source code.",
+ 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}",
},
{
- Command: "gopls.check_upgrades",
- Title: "Check for upgrades",
- Doc: "Checks for module upgrades.",
- ArgDoc: "{\n\t// The go.mod file URI.\n\t\"URI\": string,\n\t// The modules to check.\n\t\"Modules\": []string,\n}",
- ResultDoc: "",
+ Command: "gopls.check_upgrades",
+ Title: "Check for upgrades",
+ Doc: "Checks for module upgrades.",
+ ArgDoc: "{\n\t// The go.mod file URI.\n\t\"URI\": string,\n\t// The modules to check.\n\t\"Modules\": []string,\n}",
},
{
- Command: "gopls.gc_details",
- Title: "Toggle gc_details",
- Doc: "Toggle the calculation of gc annotations.",
- ArgDoc: "string",
- ResultDoc: "",
+ Command: "gopls.gc_details",
+ Title: "Toggle gc_details",
+ Doc: "Toggle the calculation of gc annotations.",
+ ArgDoc: "string",
},
{
- Command: "gopls.generate",
- Title: "Run go generate",
- Doc: "Runs `go generate` for a given directory.",
- 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}",
- ResultDoc: "",
+ Command: "gopls.generate",
+ Title: "Run go generate",
+ Doc: "Runs `go generate` for a given directory.",
+ 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}",
},
{
- Command: "gopls.generate_gopls_mod",
- Title: "Generate gopls.mod",
- Doc: "(Re)generate the gopls.mod file for a workspace.",
- ArgDoc: "{\n\t// The file URI.\n\t\"URI\": string,\n}",
- ResultDoc: "",
+ Command: "gopls.generate_gopls_mod",
+ Title: "Generate gopls.mod",
+ Doc: "(Re)generate the gopls.mod file for a workspace.",
+ ArgDoc: "{\n\t// The file URI.\n\t\"URI\": string,\n}",
},
{
- Command: "gopls.go_get_package",
- Title: "go get a package",
- Doc: "Runs `go get` to fetch a package.",
- 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}",
- ResultDoc: "",
+ Command: "gopls.go_get_package",
+ Title: "go get a package",
+ Doc: "Runs `go get` to fetch a package.",
+ 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}",
},
{
Command: "gopls.list_known_packages",
@@ -834,25 +630,22 @@
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}",
},
{
- Command: "gopls.regenerate_cgo",
- Title: "Regenerate cgo",
- Doc: "Regenerates cgo definitions.",
- ArgDoc: "{\n\t// The file URI.\n\t\"URI\": string,\n}",
- ResultDoc: "",
+ Command: "gopls.regenerate_cgo",
+ Title: "Regenerate cgo",
+ Doc: "Regenerates cgo definitions.",
+ ArgDoc: "{\n\t// The file URI.\n\t\"URI\": string,\n}",
},
{
- Command: "gopls.remove_dependency",
- Title: "Remove a dependency",
- Doc: "Removes a dependency from the go.mod file of a module.",
- 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}",
- ResultDoc: "",
+ Command: "gopls.remove_dependency",
+ Title: "Remove a dependency",
+ Doc: "Removes a dependency from the go.mod file of a module.",
+ 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}",
},
{
- Command: "gopls.run_tests",
- Title: "Run test(s)",
- Doc: "Runs `go test` for a specific set of test or benchmark functions.",
- 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}",
- ResultDoc: "",
+ Command: "gopls.run_tests",
+ Title: "Run test(s)",
+ Doc: "Runs `go test` for a specific set of test or benchmark functions.",
+ 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}",
},
{
Command: "gopls.start_debugging",
@@ -862,52 +655,45 @@
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}",
},
{
- Command: "gopls.test",
- Title: "Run test(s) (legacy)",
- Doc: "Runs `go test` for a specific set of test or benchmark functions.",
- ArgDoc: "string,\n[]string,\n[]string",
- ResultDoc: "",
+ Command: "gopls.test",
+ Title: "Run test(s) (legacy)",
+ Doc: "Runs `go test` for a specific set of test or benchmark functions.",
+ ArgDoc: "string,\n[]string,\n[]string",
},
{
- Command: "gopls.tidy",
- Title: "Run go mod tidy",
- Doc: "Runs `go mod tidy` for a module.",
- ArgDoc: "{\n\t// The file URIs.\n\t\"URIs\": []string,\n}",
- ResultDoc: "",
+ Command: "gopls.tidy",
+ Title: "Run go mod tidy",
+ Doc: "Runs `go mod tidy` for a module.",
+ ArgDoc: "{\n\t// The file URIs.\n\t\"URIs\": []string,\n}",
},
{
- Command: "gopls.toggle_gc_details",
- Title: "Toggle gc_details",
- Doc: "Toggle the calculation of gc annotations.",
- ArgDoc: "{\n\t// The file URI.\n\t\"URI\": string,\n}",
- ResultDoc: "",
+ Command: "gopls.toggle_gc_details",
+ Title: "Toggle gc_details",
+ Doc: "Toggle the calculation of gc annotations.",
+ ArgDoc: "{\n\t// The file URI.\n\t\"URI\": string,\n}",
},
{
- Command: "gopls.update_go_sum",
- Title: "Update go.sum",
- Doc: "Updates the go.sum file for a module.",
- ArgDoc: "{\n\t// The file URIs.\n\t\"URIs\": []string,\n}",
- ResultDoc: "",
+ Command: "gopls.update_go_sum",
+ Title: "Update go.sum",
+ Doc: "Updates the go.sum file for a module.",
+ ArgDoc: "{\n\t// The file URIs.\n\t\"URIs\": []string,\n}",
},
{
- Command: "gopls.upgrade_dependency",
- Title: "Upgrade a dependency",
- Doc: "Upgrades a dependency in the go.mod file for a module.",
- 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}",
- ResultDoc: "",
+ Command: "gopls.upgrade_dependency",
+ Title: "Upgrade a dependency",
+ Doc: "Upgrades a dependency in the go.mod file for a module.",
+ 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}",
},
{
- Command: "gopls.vendor",
- Title: "Run go mod vendor",
- Doc: "Runs `go mod vendor` for a module.",
- ArgDoc: "{\n\t// The file URI.\n\t\"URI\": string,\n}",
- ResultDoc: "",
+ Command: "gopls.vendor",
+ Title: "Run go mod vendor",
+ Doc: "Runs `go mod vendor` for a module.",
+ ArgDoc: "{\n\t// The file URI.\n\t\"URI\": string,\n}",
},
{
Command: "gopls.workspace_metadata",
Title: "Query workspace metadata",
Doc: "Query the server for information about active workspaces.",
- ArgDoc: "",
ResultDoc: "{\n\t// All workspaces for this session.\n\t\"Workspaces\": []{\n\t\t\"Name\": string,\n\t\t\"ModuleDir\": string,\n\t},\n}",
},
},
@@ -1005,9 +791,8 @@
Default: true,
},
{
- Name: "fieldalignment",
- Doc: "find structs that would use less memory if their fields were sorted\n\nThis analyzer find structs that can be rearranged to use less memory, and provides\na suggested edit with the optimal order.\n\nNote that there are two different diagnostics reported. One checks struct size,\nand the other reports \"pointer bytes\" used. Pointer bytes is how many bytes of the\nobject that the garbage collector has to potentially scan for pointers, for example:\n\n\tstruct { uint32; string }\n\nhave 16 pointer bytes because the garbage collector has to scan up through the string's\ninner pointer.\n\n\tstruct { string; *uint32 }\n\nhas 24 pointer bytes because it has to scan further through the *uint32.\n\n\tstruct { string; uint32 }\n\nhas 8 because it can stop immediately after the string pointer.\n",
- Default: false,
+ Name: "fieldalignment",
+ Doc: "find structs that would use less memory if their fields were sorted\n\nThis analyzer find structs that can be rearranged to use less memory, and provides\na suggested edit with the optimal order.\n\nNote that there are two different diagnostics reported. One checks struct size,\nand the other reports \"pointer bytes\" used. Pointer bytes is how many bytes of the\nobject that the garbage collector has to potentially scan for pointers, for example:\n\n\tstruct { uint32; string }\n\nhave 16 pointer bytes because the garbage collector has to scan up through the string's\ninner pointer.\n\n\tstruct { string; *uint32 }\n\nhas 24 pointer bytes because it has to scan further through the *uint32.\n\n\tstruct { string; uint32 }\n\nhas 8 because it can stop immediately after the string pointer.\n",
},
{
Name: "httpresponse",
@@ -1040,9 +825,8 @@
Default: true,
},
{
- Name: "nilness",
- Doc: "check for redundant or impossible nil comparisons\n\nThe nilness checker inspects the control-flow graph of each function in\na package and reports nil pointer dereferences, degenerate nil\npointers, and panics with nil values. A degenerate comparison is of the form\nx==nil or x!=nil where x is statically known to be nil or non-nil. These are\noften a mistake, especially in control flow related to errors. Panics with nil\nvalues are checked because they are not detectable by\n\n\tif r := recover(); r != nil {\n\nThis check reports conditions such as:\n\n\tif f == nil { // impossible condition (f is a function)\n\t}\n\nand:\n\n\tp := &v\n\t...\n\tif p != nil { // tautological condition\n\t}\n\nand:\n\n\tif p == nil {\n\t\tprint(*p) // nil dereference\n\t}\n\nand:\n\n\tif p == nil {\n\t\tpanic(p)\n\t}\n",
- Default: false,
+ Name: "nilness",
+ Doc: "check for redundant or impossible nil comparisons\n\nThe nilness checker inspects the control-flow graph of each function in\na package and reports nil pointer dereferences, degenerate nil\npointers, and panics with nil values. A degenerate comparison is of the form\nx==nil or x!=nil where x is statically known to be nil or non-nil. These are\noften a mistake, especially in control flow related to errors. Panics with nil\nvalues are checked because they are not detectable by\n\n\tif r := recover(); r != nil {\n\nThis check reports conditions such as:\n\n\tif f == nil { // impossible condition (f is a function)\n\t}\n\nand:\n\n\tp := &v\n\t...\n\tif p != nil { // tautological condition\n\t}\n\nand:\n\n\tif p == nil {\n\t\tprint(*p) // nil dereference\n\t}\n\nand:\n\n\tif p == nil {\n\t\tpanic(p)\n\t}\n",
},
{
Name: "printf",
@@ -1050,9 +834,8 @@
Default: true,
},
{
- Name: "shadow",
- Doc: "check for possible unintended shadowing of variables\n\nThis analyzer check for shadowed variables.\nA shadowed variable is a variable declared in an inner scope\nwith the same name and type as a variable in an outer scope,\nand where the outer variable is mentioned after the inner one\nis declared.\n\n(This definition can be refined; the module generates too many\nfalse positives and is not yet enabled by default.)\n\nFor example:\n\n\tfunc BadRead(f *os.File, buf []byte) error {\n\t\tvar err error\n\t\tfor {\n\t\t\tn, err := f.Read(buf) // shadows the function variable 'err'\n\t\t\tif err != nil {\n\t\t\t\tbreak // causes return of wrong value\n\t\t\t}\n\t\t\tfoo(buf)\n\t\t}\n\t\treturn err\n\t}\n",
- Default: false,
+ Name: "shadow",
+ Doc: "check for possible unintended shadowing of variables\n\nThis analyzer check for shadowed variables.\nA shadowed variable is a variable declared in an inner scope\nwith the same name and type as a variable in an outer scope,\nand where the outer variable is mentioned after the inner one\nis declared.\n\n(This definition can be refined; the module generates too many\nfalse positives and is not yet enabled by default.)\n\nFor example:\n\n\tfunc BadRead(f *os.File, buf []byte) error {\n\t\tvar err error\n\t\tfor {\n\t\t\tn, err := f.Read(buf) // shadows the function variable 'err'\n\t\t\tif err != nil {\n\t\t\t\tbreak // causes return of wrong value\n\t\t\t}\n\t\t\tfoo(buf)\n\t\t}\n\t\treturn err\n\t}\n",
},
{
Name: "shift",
@@ -1120,9 +903,8 @@
Default: true,
},
{
- Name: "unusedparams",
- 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",
- Default: false,
+ Name: "unusedparams",
+ 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",
},
{
Name: "unusedresult",
@@ -1130,9 +912,8 @@
Default: true,
},
{
- Name: "unusedwrite",
- Doc: "checks for unused writes\n\nThe analyzer reports instances of writes to struct fields and\narrays that are never read. Specifically, when a struct object\nor an array is copied, its elements are copied implicitly by\nthe compiler, and any element write to this copy does nothing\nwith the original object.\n\nFor example:\n\n\ttype T struct { x int }\n\tfunc f(input []T) {\n\t\tfor i, v := range input { // v is a copy\n\t\t\tv.x = i // unused write to field x\n\t\t}\n\t}\n\nAnother example is about non-pointer receiver:\n\n\ttype T struct { x int }\n\tfunc (t T) f() { // t is a copy\n\t\tt.x = i // unused write to field x\n\t}\n",
- Default: false,
+ Name: "unusedwrite",
+ Doc: "checks for unused writes\n\nThe analyzer reports instances of writes to struct fields and\narrays that are never read. Specifically, when a struct object\nor an array is copied, its elements are copied implicitly by\nthe compiler, and any element write to this copy does nothing\nwith the original object.\n\nFor example:\n\n\ttype T struct { x int }\n\tfunc f(input []T) {\n\t\tfor i, v := range input { // v is a copy\n\t\t\tv.x = i // unused write to field x\n\t\t}\n\t}\n\nAnother example is about non-pointer receiver:\n\n\ttype T struct { x int }\n\tfunc (t T) f() { // t is a copy\n\t\tt.x = i // unused write to field x\n\t}\n",
},
{
Name: "useany",