], "aliases": [ "Go Work File" ], "configuration": "./languages/go.mod.language-configuration.json" }, { "id": "go.sum", "filenames": [ "go.sum" ], "aliases": [ "Go Checksum File" ] }, { "id": "gotmpl", "extensions": [ ".tmpl", ".gotmpl" ], "aliases": [ "Go Template File" ] } ], "grammars": [ { "language": "go.mod", "scopeName": "go.mod", "path": "./syntaxes/go.mod.tmGrammar.json" }, { "language": "go.work", "scopeName": "go.mod", "path": "./syntaxes/go.mod.tmGrammar.json" }, { "language": "go.sum", "scopeName": "go.sum", "path": "./syntaxes/go.sum.tmGrammar.json" } ], "snippets": [ { "language": "go", "path": "./snippets/go.json" } ], "configurationDefaults": { "[go]": { "editor.insertSpaces": false, "editor.formatOnSave": true, "editor.codeActionsOnSave": { "source.organizeImports": "explicit" } } }, "commands": [ { "command": "go.gopath", "title": "Go: Current GOPATH", "description": "See the currently set GOPATH." }, { "command": "go.goroot", "title": "Go: Current GOROOT", "description": "See the currently set GOROOT." }, { "command": "go.locate.tools", "title": "Go: Locate Configured Go Tools", "description": "List all the Go tools being used by this extension along with their locations." }, { "command": "go.test.cursor", "title": "Go: Test Function At Cursor", "description": "Runs a unit test at the cursor." }, { "command": "go.test.cursorOrPrevious", "title": "Go: Test Function At Cursor or Test Previous", "description": "Runs a unit test at the cursor if one is found, otherwise re-runs the last executed test." }, { "command": "go.subtest.cursor", "title": "Go: Subtest At Cursor", "description": "Runs a sub test at the cursor." }, { "command": "go.debug.subtest.cursor", "title": "Go: Debug Subtest At Cursor", "description": "Debug a sub test at the cursor." }, { "command": "go.benchmark.cursor", "title": "Go: Benchmark Function At Cursor", "description": "Runs a benchmark at the cursor." }, { "command": "go.debug.cursor", "title": "Go: Debug Test At Cursor", "description": "Debug test at the cursor." }, { "command": "go.test.file", "title": "Go: Test File", "description": "Runs all unit tests in the current file." }, { "command": "go.test.package", "title": "Go: Test Package", "description": "Runs all unit tests in the package of the current file." }, { "command": "go.debug.toggleHideSystemGoroutines", "title": "Go: Toggle Hide System Goroutines", "description": "Toggles hiding the system goroutines from the active debug session call stack view." }, { "command": "go.test.refresh", "title": "Go Test: Refresh", "description": "Refresh a test in the test explorer. Only available as a context menu option in the test explorer.", "category": "Test", "icon": "$(refresh)" }, { "command": "go.test.showProfiles", "title": "Go Test: Show Last Profile", "description": "Show last captured profile", "category": "Test" }, { "command": "go.test.captureProfile", "title": "Go Test: Profile", "description": "Run a test and capture a profile", "category": "Test" }, { "command": "go.test.deleteProfile", "title": "Go Test: Delete Profile", "shortTitle": "Delete", "description": "Delete selected profile", "category": "Test" }, { "command": "go.test.showProfileFile", "title": "Go: Show pprof file", "description": "Internal use. Open a pprof profile file." }, { "command": "go.benchmark.package", "title": "Go: Benchmark Package", "description": "Runs all benchmarks in the package of the current file." }, { "command": "go.benchmark.file", "title": "Go: Benchmark File", "description": "Runs all benchmarks in the current file." }, { "command": "go.test.workspace", "title": "Go: Test All Packages In Workspace", "description": "Runs all unit tests from all packages in the current workspace." }, { "command": "go.test.previous", "title": "Go: Test Previous", "description": "Re-runs the last executed test." }, { "command": "go.debug.previous", "title": "Go: Debug Previous", "description": "Re-runs the last debugged test run through a codelens or \"Go: Debug Test at Cursor\" command." }, { "command": "go.test.coverage", "title": "Go: Toggle Test Coverage In Current Package", "description": "Displays test coverage in the current package." }, { "command": "go.test.generate.package", "title": "Go: Generate Unit Tests For Package", "description": "Generates unit tests for the current package" }, { "command": "go.test.generate.file", "title": "Go: Generate Unit Tests For File", "description": "Generates unit tests for the current file" }, { "command": "go.test.generate.function", "title": "Go: Generate Unit Tests For Function", "description": "Generates unit tests for the selected function in the current file" }, { "command": "go.impl.cursor", "title": "Go: Generate Interface Stubs", "description": "Generates method stub for implementing the provided interface and inserts at the cursor." }, { "command": "go.extractServerChannel", "title": "Go: Extract Language Server Logs To Editor", "description": "Extract logs in the `gopls (server)` output channel to the editor." }, { "command": "go.welcome", "title": "Go: Welcome", "description": "Open the welcome page for the Go extension." }, { "command": "go.toggle.gc_details", "title": "Go: Toggle gc details", "description": "Toggle the display of compiler optimization choices" }, { "command": "go.import.add", "title": "Go: Add Import", "description": "Add an import declaration" }, { "command": "go.add.package.workspace", "title": "Go: Add Package to Workspace", "description": "Add a package from the imports list to the workspace." }, { "command": "go.tools.install", "title": "Go: Install/Update Tools", "description": "install/update the required go packages" }, { "command": "go.toggle.test.file", "title": "Go: Toggle Test File", "description": "Toggles between file in current active editor and the corresponding test file." }, { "command": "go.vulncheck.toggle", "title": "Go: Toggle Vulncheck", "description": "Toggle the display of vulnerability analysis in dependencies." }, { "command": "go.languageserver.maintain", "title": "Go: Start language server's maintainer interface", "description": "Start the Go language server's maintainer interface (a web server)." }, { "command": "go.add.tags", "title": "Go: Add Tags To Struct Fields", "description": "Add tags configured in go.addTags setting to selected struct using gomodifytags" }, { "command": "go.remove.tags", "title": "Go: Remove Tags From Struct Fields", "description": "Remove tags configured in go.removeTags setting from selected struct using gomodifytags" }, { "command": "go.show.commands", "title": "Go: Show All Commands...", "description": "Shows all commands from the Go extension in the quick pick" }, { "command": "go.browse.packages", "title": "Go: Browse Packages", "description": "Browse packages and Go files inside the packages." }, { "command": "go.get.package", "title": "Go: Get Package", "description": "Run `go get -v` on the package on the current line." }, { "command": "go.playground", "title": "Go: Run on Go Playground", "description": "Upload the current selection or file to the Go Playground" }, { "command": "go.lint.package", "title": "Go: Lint Current Package", "description": "Run linter in the package of the current file." }, { "command": "go.lint.workspace", "title": "Go: Lint Workspace", "description": "Run linter in the current workspace." }, { "command": "go.vet.package", "title": "Go: Vet Current Package", "description": "Run go vet in the package of the current file." }, { "command": "go.vet.workspace", "title": "Go: Vet Workspace", "description": "Run go vet in the current workspace." }, { "command": "go.build.package", "title": "Go: Build Current Package", "description": "Build the package of the current file." }, { "command": "go.build.workspace", "title": "Go: Build Workspace", "description": "Build the current workspace." }, { "command": "go.install.package", "title": "Go: Install Current Package", "description": "Install the current package." }, { "command": "go.run.modinit", "title": "Go: Initialize go.mod", "description": "Run `go mod init` in the workspace folder." }, { "command": "go.test.cancel", "title": "Go: Cancel Running Tests", "description": "Cancels running tests." }, { "command": "go.apply.coverprofile", "title": "Go: Apply Cover Profile", "description": "Applies existing cover profile." }, { "command": "go.languageserver.restart", "title": "Go: Restart Language Server", "description": "Restart the running instance of the language server" }, { "command": "go.environment.choose", "title": "Go: Choose Go Environment", "description": "Choose a different Go version or binary for this project. (WIP)" }, { "command": "go.survey.showConfig", "title": "Go: Show Survey Configuration", "description": "Show the current Go survey configuration" }, { "command": "go.survey.resetConfig", "title": "Go: Reset Survey Configuration", "description": "Reset the current Go survey configuration history" }, { "command": "go.workspace.resetState", "title": "Go: Reset Workspace State", "description": "Reset keys in workspace state to undefined." }, { "command": "go.global.resetState", "title": "Go: Reset Global State", "description": "Reset keys in global state to undefined." }, { "command": "go.explorer.refresh", "title": "Go Explorer: Refresh", "description": "Refresh the Go explorer. Only available as a menu item in the explorer.", "category": "Explorer", "icon": "$(refresh)" }, { "command": "go.explorer.open", "title": "Go Explorer: Open File", "description": "Open a file from the Go explorer. Only available as a menu item in the explorer.", "category": "Explorer", "icon": "$(go-to-file)" }, { "command": "go.workspace.editEnv", "title": "Go: Edit Workspace Env", "description": "Edit the Go Env for the active workspace.", "icon": "$(settings-edit)", "enablement": "workspaceFolderCount > 0" }, { "command": "go.workspace.resetEnv", "title": "Go: Reset Workspace Env", "description": "Reset the Go Env for the active workspace.", "icon": "$(settings-remove)", "enablement": "workspaceFolderCount > 0" } ], "breakpoints": [ { "language": "go" } ], "debuggers": [ { "type": "go", "label": "Go", "program": "./dist/debugAdapter.js", "runtime": "node", "languages": [ "go" ], "variables": { "pickProcess": "go.debug.pickProcess", "pickGoProcess": "go.debug.pickGoProcess" }, "configurationSnippets": [ { "label": "Go: Launch package", "description": "Debug/test the package in the program attribute", "body": { "name": "${2:Launch Package}", "type": "go", "request": "launch", "mode": "auto", "program": "^\"\\${workspaceFolder}${1:}\"" } }, { "label": "Go: Launch file", "description": "Debug the file in the program attribute", "body": { "name": "${2:Launch file}", "type": "go", "request": "launch", "mode": "debug", "program": "^\"${1:\\${file\\}}\"" } }, { "label": "Go: Launch test function", "description": "Debug the test function in the args, ensure program attributes points to right package", "body": { "name": "${3:Launch test function}", "type": "go", "request": "launch", "mode": "test", "program": "^\"\\${workspaceFolder}${1:}\"", "args": [ "-test.run", "${2:MyTestFunction}" ] } }, { "label": "Go: Attach to local process", "description": "Attach to an existing process by process ID", "body": { "name": "${1:Attach to Process}", "type": "go", "request": "attach", "mode": "local", "processId": 0 } }, { "label": "Go: Connect to server", "description": "Connect to a remote headless debug server", "body": { "name": "${1:Connect to server}", "type": "go", "request": "attach", "mode": "remote", "remotePath": "^\"\\${workspaceFolder}\"", "port": 2345, "host": "127.0.0.1" } } ], "configurationAttributes": { "launch": { "required": [], "properties": { "debugAdapter": { "enum": [ "legacy", "dlv-dap" ], "description": "Select which debug adapter to use with this launch configuration.", "default": "dlv-dap" }, "program": { "type": "string", "description": "Path to the program folder (or any go file within that folder) when in `debug` or `test` mode, and to the pre-built binary file to debug in `exec` mode. If it is not an absolute path, the extension interpretes it as a workspace relative path.", "default": "${workspaceFolder}" }, "mode": { "enum": [ "auto", "debug", "test", "exec", "replay", "core" ], "description": "One of `auto`, `debug`, `test`, `exec`, `replay`, `core`. In `auto` mode, the extension will choose either `debug` or `test` depending on active editor window.", "default": "auto" }, "traceDirPath": { "type": "string", "description": "Directory in which the record trace is located or to be created for a new output trace. For use on 'replay' mode only", "default": "" }, "coreFilePath": { "type": "string", "description": "Path to the core dump file to open. For use on 'core' mode only", "default": "" }, "stopOnEntry": { "type": "boolean", "description": "Automatically stop program after launch.", "default": false }, "args": { "type": [ "array", "string" ], "description": "Command line arguments passed to the debugged program.", "items": { "type": "string" }, "default": [] }, "showLog": { "type": "boolean", "description": "Show log output from the delve debugger. Maps to dlv's `--log` flag.", "default": false }, "cwd": { "type": "string", "description": "Workspace relative or absolute path to the working directory of the program being debugged if a non-empty value is specified. The `program` folder is used as the working directory if `cwd` is omitted or empty.", "default": "" }, "env": { "type": "object", "description": "Environment variables passed to the launched debuggee program. Format as string key:value pairs. Merged with `envFile` and `go.toolsEnvVars` with precedence `env` > `envFile` > `go.toolsEnvVars`.", "default": {} }, "substitutePath": { "type": "array", "items": { "type": "object", "properties": { "from": { "type": "string", "description": "The absolute local path to be replaced when passing paths to the debugger.", "default": "" }, "to": { "type": "string", "description": "The absolute remote path to be replaced when passing paths back to the client.", "default": "" } } }, "description": "An array of mappings from a local path (editor) to the remote path (debugee). This setting is useful when working in a file system with symbolic links, running remote debugging, or debugging an executable compiled externally. The debug adapter will replace the local path with the remote path in all of the calls.", "default": [] }, "buildFlags": { "type": [ "string", "array" ], "items": { "type": "string" }, "description": "Build flags, to be passed to the Go compiler. Maps to dlv's `--build-flags` flag.", "default": [] }, "dlvFlags": { "type": "array", "description": "Extra flags for `dlv`. See `dlv help` for the full list of supported. Flags such as `--log-output`, `--log`, `--log-dest`, `--api-version`, `--output`, `--backend` already have corresponding properties in the debug configuration, and flags such as `--listen` and `--headless` are used internally. If they are specified in `dlvFlags`, they may be ignored or cause an error.", "items": { "type": "string" }, "default": [] }, "port": { "type": "number", "description": "When applied to remote-attach configurations, will look for \"dlv ... --headless --listen=:\" server started externally. In dlv-dap mode this will apply to all other configurations as well. The extension will try to connect to an external server started with \"dlv dap --listen=:\" to ask it to launch/attach to the target process.", "default": 2345 }, "host": { "type": "string", "description": "When applied to remote-attach configurations, will look for \"dlv ... --headless --listen=:\" server started externally. In dlv-dap mode this will apply to all other configurations as well. The extension will try to connect to an external server started with \"dlv dap --listen=:\" to ask it to launch/attach to the target process.", "default": "127.0.0.1" }, "trace": { "type": "string", "enum": [ "verbose", "trace", "log", "info", "warn", "error" ], "default": "error", "description": "Various levels of logging shown in the debug console & 'Go Debug' output channel. When using the `legacy` debug adapter, the logs will also be written to a file if it is set to a value other than `error`." }, "envFile": { "type": [ "string", "array" ], "items": { "type": "string" }, "description": "Absolute path to a file containing environment variable definitions, formatted as string key=value pairs. Multiple files can be specified by provided an array of absolute paths. Merged with `env` and `go.toolsEnvVars` with precedence `env` > `envFile` > `go.toolsEnvVars`. ", "default": "" }, "backend": { "type": "string", "enum": [ "default", "native", "lldb", "rr" ], "description": "Backend used by delve. Maps to `dlv`'s `--backend` flag." }, "output": { "type": "string", "description": "Output path for the binary of the debugee.", "default": "debug" }, "logOutput": { "type": "string", "enum": [ "debugger", "gdbwire", "lldbout", "debuglineerr", "rpc", "dap" ], "description": "Comma separated list of components that should produce debug output. Maps to dlv's `--log-output` flag. Check `dlv log` for details.", "default": "debugger" }, "logDest": { "type": "string", "description": "dlv's `--log-dest` flag. See `dlv log` for details. Number argument is not allowed. Supported only in `dlv-dap` mode, and on Linux and Mac OS." }, "dlvLoadConfig": { "type": "object", "properties": { "followPointers": { "type": "boolean", "description": "FollowPointers requests pointers to be automatically dereferenced.", "default": true }, "maxVariableRecurse": { "type": "number", "description": "MaxVariableRecurse is how far to recurse when evaluating nested types.", "default": 1 }, "maxStringLen": { "type": "number", "description": "MaxStringLen is the maximum number of bytes read from a string.", "default": 64 }, "maxArrayValues": { "type": "number", "description": "MaxArrayValues is the maximum number of elements read from an array, a slice or a map.", "default": 64 }, "maxStructFields": { "type": "number", "description": "MaxStructFields is the maximum number of fields read from a struct, -1 will read all fields.", "default": -1 } }, "description": "LoadConfig describes to delve, how to load values from target's memory. Not applicable when using `dlv-dap` mode.", "default": { "followPointers": true, "maxVariableRecurse": 1, "maxStringLen": 64, "maxArrayValues": 64, "maxStructFields": -1 } }, "apiVersion": { "type": "number", "enum": [ 1, 2 ], "description": "Delve Api Version to use. Default value is 2. Maps to dlv's `--api-version` flag. Not applicable when using `dlv-dap` mode.", "default": 2 }, "stackTraceDepth": { "type": "number", "description": "Maximum depth of stack trace collected from Delve.", "default": 50 }, "showGlobalVariables": { "type": "boolean", "default": false, "description": "Boolean value to indicate whether global package variables should be shown in the variables pane or not." }, "showRegisters": { "type": "boolean", "default": false, "description": "Boolean value to indicate whether register variables should be shown in the variables pane or not." }, "hideSystemGoroutines": { "type": "boolean", "default": false, "description": "Boolean value to indicate whether system goroutines should be hidden from call stack view." }, "console": { "default": "internalConsole", "description": "(Experimental) Where to launch the debugger and the debug target: internal console, integrated terminal, or external terminal. It is ignored in remote debugging.", "enum": [ "internalConsole", "integratedTerminal", "externalTerminal" ] }, "asRoot": { "default": false, "description": "(Experimental) Debug with elevated permissions (on Unix). It requires `integrated` or `external` console modes and is ignored in remote debugging.", "type": "boolean" } } }, "attach": { "required": [], "properties": { "debugAdapter": { "enum": [ "legacy", "dlv-dap" ], "description": "Select which debug adapter to use with this launch configuration.", "default": "dlv-dap" }, "processId": { "anyOf": [ { "enum": [ "${command:pickProcess}", "${command:pickGoProcess}" ], "description": "Use process picker to select a process to attach, or Process ID as integer." }, { "type": "string", "description": "Attach to a process by name. If more than one process matches the name, use the process picker to select a process." }, { "type": "number", "description": "The numeric ID of the process to be debugged. If 0, use the process picker to select a process." } ], "default": 0 }, "mode": { "enum": [ "local", "remote" ], "description": "Indicates local or remote debugging. Local is similar to the `dlv attach` command, remote - to `dlv connect`", "default": "local" }, "stopOnEntry": { "type": "boolean", "description": "Automatically stop program after attach.", "default": false }, "dlvFlags": { "type": "array", "description": "Extra flags for `dlv`. See `dlv help` for the full list of supported. Flags such as `--log-output`, `--log`, `--log-dest`, `--api-version`, `--output`, `--backend` already have corresponding properties in the debug configuration, and flags such as `--listen` and `--headless` are used internally. If they are specified in `dlvFlags`, they may be ignored or cause an error.", "items": { "type": "string" }, "default": [] }, "showLog": { "type": "boolean", "description": "Show log output from the delve debugger. Maps to dlv's `--log` flag.", "default": false }, "cwd": { "type": "string", "description": "Workspace relative or absolute path to the working directory of the program being debugged. Default is the current workspace.", "default": "${workspaceFolder}" }, "remotePath": { "type": "string", "description": "The path to the source code on the remote machine, when the remote path is different from the local machine. If specified, becomes the first entry in substitutePath. Not supported with `dlv-dap`.", "markdownDeprecationMessage": "Use `substitutePath` instead.", "default": "" }, "port": { "type": "number", "description": "When applied to remote-attach configurations, will look for \"dlv ... --headless --listen=:\" server started externally. In dlv-dap mode, this will apply to all other configurations as well. The extension will try to connect to an external server started with \"dlv dap --listen=:\" to ask it to launch/attach to the target process.", "default": 2345 }, "host": { "type": "string", "description": "When applied to remote-attach configurations, will look for \"dlv ... --headless --listen=:\" server started externally. In dlv-dap mode, this will apply to all other configurations as well. The extension will try to connect to an external server started with \"dlv dap --listen=:\" to ask it to launch/attach to the target process.", "default": "127.0.0.1" }, "substitutePath": { "type": "array", "items": { "type": "object", "properties": { "from": { "type": "string", "description": "The absolute local path to be replaced when passing paths to the debugger.", "default": "" }, "to": { "type": "string", "description": "The absolute remote path to be replaced when passing paths back to the client.", "default": "" } } }, "description": "An array of mappings from a local path (editor) to the remote path (debugee). This setting is useful when working in a file system with symbolic links, running remote debugging, or debugging an executable compiled externally. The debug adapter will replace the local path with the remote path in all of the calls. Overriden by `remotePath`.", "default": [] }, "trace": { "type": "string", "enum": [ "verbose", "trace", "log", "info", "warn", "error" ], "default": "error", "description": "Various levels of logging shown in the debug console & 'Go Debug' output channel. When using the `legacy` debug adapter, the logs will also be written to a file if it is set to a value other than `error`." }, "backend": { "type": "string", "enum": [ "default", "native", "lldb", "rr" ], "description": "Backend used by delve. Maps to `dlv`'s `--backend` flag." }, "logOutput": { "type": "string", "enum": [ "debugger", "gdbwire", "lldbout", "debuglineerr", "rpc", "dap" ], "description": "Comma separated list of components that should produce debug output. Maps to dlv's `--log-output` flag. Check `dlv log` for details.", "default": "debugger" }, "logDest": { "type": "string", "description": "dlv's `--log-dest` flag. See `dlv log` for details. Number argument is not allowed. Supported only in `dlv-dap` mode and on Linux and Mac OS." }, "dlvLoadConfig": { "type": "object", "properties": { "followPointers": { "type": "boolean", "description": "FollowPointers requests pointers to be automatically dereferenced", "default": true }, "maxVariableRecurse": { "type": "number", "description": "MaxVariableRecurse is how far to recurse when evaluating nested types", "default": 1 }, "maxStringLen": { "type": "number", "description": "MaxStringLen is the maximum number of bytes read from a string", "default": 64 }, "maxArrayValues": { "type": "number", "description": "MaxArrayValues is the maximum number of elements read from an array, a slice or a map", "default": 64 }, "maxStructFields": { "type": "number", "description": "MaxStructFields is the maximum number of fields read from a struct, -1 will read all fields", "default": -1 } }, "description": "LoadConfig describes to delve, how to load values from target's memory. Not applicable when using `dlv-dap` mode.", "default": { "followPointers": true, "maxVariableRecurse": 1, "maxStringLen": 64, "maxArrayValues": 64, "maxStructFields": -1 } }, "apiVersion": { "type": "number", "enum": [ 1, 2 ], "description": "Delve Api Version to use. Default value is 2. Not applicable when using `dlv-dap` mode.", "default": 2 }, "stackTraceDepth": { "type": "number", "description": "Maximum depth of stack trace collected from Delve.", "default": 50 }, "showGlobalVariables": { "type": "boolean", "default": false, "description": "Boolean value to indicate whether global package variables should be shown in the variables pane or not." }, "showRegisters": { "type": "boolean", "default": false, "description": "Boolean value to indicate whether register variables should be shown in the variables pane or not." }, "hideSystemGoroutines": { "type": "boolean", "default": false, "description": "Boolean value to indicate whether system goroutines should be hidden from call stack view." }, "console": { "default": "internalConsole", "description": "(Experimental) Where to launch the debugger: internal console, integrated terminal, or external terminal. This does not affect tty of the running program. It is ignored in remote debugging.", "enum": [ "internalConsole", "integratedTerminal", "externalTerminal" ] }, "asRoot": { "default": false, "description": "(Experimental) Debug with elevated permissions (on Unix). This requires `integrated` or `external` console modes and is ignored in remote debugging.", "type": "boolean" } } } } } ], "configuration": { "type": "object", "title": "Go", "properties": { "go.showWelcome": { "type": "boolean", "default": true, "description": "Specifies whether to show the Welcome experience on first install" }, "go.buildOnSave": { "type": "string", "enum": [ "package", "workspace", "off" ], "default": "package", "description": "Compiles code on file save using 'go build' or 'go test -c'. Not applicable when using the language server.", "scope": "resource", "markdownDeprecationMessage": "Enable the Go language server (`#go.useLanguageServer#`) to diagnose compile errors." }, "go.buildFlags": { "type": "array", "items": { "type": "string" }, "default": [], "description": "Flags to `go build`/`go test` used during build-on-save or running tests. (e.g. [\"-ldflags='-s'\"]) This is propagated to the language server if `gopls.build.buildFlags` is not specified.", "scope": "resource" }, "go.buildTags": { "type": "string", "default": "", "description": "The Go build tags to use for all commands, that support a `-tags '...'` argument. When running tests, go.testTags will be used instead if it was set. This is propagated to the language server if `gopls.build.buildFlags` is not specified.", "scope": "resource" }, "go.testTags": { "type": [ "string", "null" ], "default": null, "description": "The Go build tags to use for when running tests. If null, then buildTags will be used.", "scope": "resource" }, "go.disableConcurrentTests": { "type": "boolean", "default": false, "description": "If true, tests will not run concurrently. When a new test run is started, the previous will be cancelled.", "scope": "resource" }, "go.installDependenciesWhenBuilding": { "type": "boolean", "default": false, "description": "If true, then `-i` flag will be passed to `go build` everytime the code is compiled. Since Go 1.10, setting this may be unnecessary unless you are in GOPATH mode and do not use the language server.", "scope": "resource" }, "go.lintOnSave": { "type": "string", "enum": [ "file", "package", "workspace", "off" ], "enumDescriptions": [ "lint the current file on file saving", "lint the current package on file saving", "lint all the packages in the current workspace root folder on file saving", "do not run lint automatically" ], "default": "package", "description": "Lints code on file save using the configured Lint tool. Options are 'file', 'package', 'workspace' or 'off'.", "scope": "resource" }, "go.lintTool": { "type": "string", "default": "staticcheck", "description": "Specifies Lint tool name.", "scope": "resource", "enum": [ "staticcheck", "golint", "golangci-lint", "revive" ] }, "go.lintFlags": { "type": "array", "items": { "type": "string" }, "default": [], "description": "Flags to pass to Lint tool (e.g. [\"-min_confidence=.8\"])", "scope": "resource" }, "go.vetOnSave": { "type": "string", "enum": [ "package", "workspace", "off" ], "enumDescriptions": [ "vet the current package on file saving", "vet all the packages in the current workspace root folder on file saving", "do not run vet automatically" ], "default": "package", "description": "Vets code on file save using 'go tool vet'. Not applicable when using the language server's diagnostics.", "scope": "resource" }, "go.vetFlags": { "type": "array", "items": { "type": "string" }, "default": [], "description": "Flags to pass to `go tool vet` (e.g. [\"-all\", \"-shadow\"]). Not applicable when using the language server's diagnostics.", "scope": "resource" }, "go.formatTool": { "type": "string", "default": "default", "markdownDescription": "When the language server is enabled and one of `default`/`gofmt`/`goimports`/`gofumpt` is chosen, the language server will handle formatting. If `custom` tool is selected, the extension will use the `customFormatter` tool in the `#go.alternateTools#` section.", "scope": "resource", "enum": [ "default", "gofmt", "goimports", "goformat", "gofumpt", "custom" ], "markdownEnumDescriptions": [ "If the language server is enabled, format via the language server, which already supports gofmt, goimports, goreturns, and gofumpt. Otherwise, goimports.", "Formats the file according to the standard Go style. (not applicable when the language server is enabled)", "Organizes imports and formats the file with gofmt. (not applicable when the language server is enabled)", "Configurable gofmt, see https://github.com/mbenkmann/goformat.", "Stricter version of gofmt, see https://github.com/mvdan/gofumpt. . Use `#gopls.format.gofumpt#` instead)", "Formats using the custom tool specified as `customFormatter` in the `#go.alternateTools#` setting. The tool should take the input as STDIN and output the formatted code as STDOUT." ] }, "go.formatFlags": { "type": "array", "items": { "type": "string" }, "default": [], "description": "Flags to pass to format tool (e.g. [\"-s\"]). Not applicable when using the language server.", "scope": "resource" }, "go.inferGopath": { "type": "boolean", "default": false, "description": "Infer GOPATH from the workspace root. This is ignored when using Go Modules.", "scope": "resource" }, "go.gopath": { "type": [ "string", "null" ], "default": null, "description": "Specify GOPATH here to override the one that is set as environment variable. The inferred GOPATH from workspace root overrides this, if go.inferGopath is set to true.", "scope": "machine-overridable" }, "go.toolsGopath": { "type": [ "string", "null" ], "default": null, "description": "Location to install the Go tools that the extension depends on if you don't want them in your GOPATH.", "scope": "machine-overridable" }, "go.goroot": { "type": [ "string", "null" ], "default": null, "description": "Specifies the GOROOT to use when no environment variable is set.", "scope": "machine-overridable" }, "go.testOnSave": { "type": "boolean", "default": false, "description": "Run 'go test' on save for current package. It is not advised to set this to `true` when you have Auto Save enabled.", "scope": "resource" }, "go.coverOnSave": { "type": "boolean", "default": false, "description": "If true, runs 'go test -coverprofile' on save and shows test coverage.", "scope": "resource" }, "go.coverOnTestPackage": { "type": "boolean", "default": true, "description": "If true, shows test coverage when Go: Test Package command is run." }, "go.coverOnSingleTest": { "type": "boolean", "default": false, "description": "If true, shows test coverage when Go: Test Function at cursor command is run." }, "go.coverOnSingleTestFile": { "type": "boolean", "default": false, "description": "If true, shows test coverage when Go: Test Single File command is run." }, "go.coverMode": { "type": "string", "enum": [ "default", "set", "count", "atomic" ], "default": "default", "description": "When generating code coverage, the value for -covermode. 'default' is the default value chosen by the 'go test' command.", "scope": "resource" }, "go.coverShowCounts": { "type": "boolean", "default": false, "description": "When generating code coverage, should counts be shown as --374--", "scope": "resource" }, "go.coverageOptions": { "type": "string", "enum": [ "showCoveredCodeOnly", "showUncoveredCodeOnly", "showBothCoveredAndUncoveredCode" ], "default": "showBothCoveredAndUncoveredCode", "description": "Use these options to control whether only covered or only uncovered code or both should be highlighted after running test coverage", "scope": "resource" }, "go.coverageDecorator": { "type": "object", "properties": { "type": { "type": "string", "enum": [ "highlight", "gutter" ] }, "coveredHighlightColor": { "type": "string", "description": "Color in the rgba format to use to highlight covered code." }, "uncoveredHighlightColor": { "type": "string", "description": "Color in the rgba format to use to highlight uncovered code." }, "coveredBorderColor": { "type": "string", "description": "Color to use for the border of covered code." }, "uncoveredBorderColor": { "type": "string", "description": "Color to use for the border of uncovered code." }, "coveredGutterStyle": { "type": "string", "enum": [ "blockblue", "blockred", "blockgreen", "blockyellow", "slashred", "slashgreen", "slashblue", "slashyellow", "verticalred", "verticalgreen", "verticalblue", "verticalyellow" ], "description": "Gutter style to indicate covered code." }, "uncoveredGutterStyle": { "type": "string", "enum": [ "blockblue", "blockred", "blockgreen", "blockyellow", "slashred", "slashgreen", "slashblue", "slashyellow", "verticalred", "verticalgreen", "verticalblue", "verticalyellow" ], "description": "Gutter style to indicate covered code." } }, "additionalProperties": false, "default": { "type": "highlight", "coveredHighlightColor": "rgba(64,128,128,0.5)", "uncoveredHighlightColor": "rgba(128,64,64,0.25)", "coveredBorderColor": "rgba(64,128,128,0.5)", "uncoveredBorderColor": "rgba(128,64,64,0.25)", "coveredGutterStyle": "blockblue", "uncoveredGutterStyle": "slashyellow" }, "description": "This option lets you choose the way to display code coverage. Choose either to highlight the complete line or to show a decorator in the gutter. You can customize the colors and borders for the former and the style for the latter.", "scope": "resource" }, "go.testTimeout": { "type": "string", "default": "30s", "description": "Specifies the timeout for go test in ParseDuration format.", "scope": "resource" }, "go.testEnvVars": { "type": "object", "default": {}, "description": "Environment variables that will be passed to the process that runs the Go tests", "scope": "resource" }, "go.testEnvFile": { "type": "string", "default": null, "description": "Absolute path to a file containing environment variables definitions. File contents should be of the form key=value.", "scope": "resource" }, "go.testFlags": { "type": [ "array", "null" ], "items": { "type": "string" }, "default": null, "description": "Flags to pass to `go test`. If null, then buildFlags will be used. This is not propagated to the language server.", "scope": "resource" }, "go.testExplorer.enable": { "type": "boolean", "default": true, "scope": "window", "description": "Enable the Go test explorer" }, "go.testExplorer.packageDisplayMode": { "type": "string", "enum": [ "flat", "nested" ], "default": "flat", "description": "Present packages in the test explorer flat or nested.", "scope": "resource" }, "go.testExplorer.alwaysRunBenchmarks": { "type": "boolean", "default": false, "description": "Run benchmarks when running all tests in a file or folder.", "scope": "resource" }, "go.testExplorer.concatenateMessages": { "type": "boolean", "default": true, "description": "Concatenate all test log messages for a given location into a single message.", "scope": "resource" }, "go.testExplorer.showDynamicSubtestsInEditor": { "type": "boolean", "default": false, "description": "Set the source location of dynamically discovered subtests to the location of the containing function. As a result, dynamically discovered subtests will be added to the gutter test widget of the containing function.", "scope": "resource" }, "go.testExplorer.showOutput": { "type": "boolean", "default": true, "description": "Open the test output terminal when a test run is started.", "scope": "window" }, "go.experiments": { "type": "object", "default": { "testExplorer": true }, "description": "Disable experimental features. These features are only available in the pre-release version.", "properties": { "testExplorer": { "type": "boolean", "default": true, "description": "Prefer the experimental test explorer" } } }, "go.generateTestsFlags": { "type": "array", "items": { "type": "string" }, "default": [], "description": "Additional command line flags to pass to `gotests` for generating tests.", "scope": "resource" }, "go.toolsEnvVars": { "type": "object", "default": {}, "description": "Environment variables that will be passed to the tools that run the Go tools (e.g. CGO_CFLAGS) and debuggee process launched by Delve. Format as string key:value pairs. When debugging, merged with `envFile` and `env` values with precedence `env` > `envFile` > `go.toolsEnvVars`.", "scope": "resource" }, "go.useLanguageServer": { "type": "boolean", "default": true, "description": "Enable intellisense, code navigation, refactoring, formatting & diagnostics for Go. The features are powered by the Go language server \"gopls\"." }, "go.languageServerFlags": { "type": "array", "default": [], "description": "Flags like -rpc.trace and -logfile to be used while running the language server." }, "go.trace.server": { "type": "string", "enum": [ "off", "messages", "verbose" ], "default": "off", "description": "Trace the communication between VS Code and the Go language server." }, "go.logging.level": { "type": "string", "deprecationMessage": "This setting is deprecated. Use 'Developer: Set Log Level...' command to control logging level instead.", "scope": "machine-overridable" }, "go.toolsManagement.go": { "type": "string", "default": "", "description": "The path to the `go` binary used to install the Go tools. If it's empty, the same `go` binary chosen for the project will be used for tool installation.", "scope": "machine-overridable" }, "go.toolsManagement.checkForUpdates": { "type": "string", "default": "proxy", "enum": [ "proxy", "local", "off" ], "enumDescriptions": [ "keeps notified of new releases by checking the Go module proxy (GOPROXY)", "checks only the minimum tools versions required by the extension", "completely disables version check (not recommended)" ], "markdownDescription": "Specify whether to prompt about new versions of Go and the Go tools (currently, only `gopls`) the extension depends on" }, "go.toolsManagement.autoUpdate": { "type": "boolean", "default": false, "description": "Automatically update the tools used by the extension, without prompting the user.", "scope": "resource" }, "go.enableCodeLens": { "type": "object", "properties": { "runtest": { "type": "boolean", "default": true, "description": "If true, enables code lens for running and debugging tests" } }, "additionalProperties": false, "default": { "runtest": true }, "description": "Feature level setting to enable/disable code lens for references and run/debug tests", "scope": "resource" }, "go.addTags": { "type": "object", "properties": { "promptForTags": { "type": "boolean", "default": false, "description": "If true, Go: Add Tags command will prompt the user to provide tags, options, transform values instead of using the configured values" }, "tags": { "type": "string", "default": "json", "description": "Comma separated tags to be used by Go: Add Tags command" }, "options": { "type": "string", "default": "json=omitempty", "description": "Comma separated tag=options pairs to be used by Go: Add Tags command" }, "transform": { "type": "string", "enum": [ "snakecase", "camelcase", "lispcase", "pascalcase", "keep" ], "default": "snakecase", "description": "Transformation rule used by Go: Add Tags command to add tags" }, "template": { "type": "string", "default": "", "description": "Custom format used by Go: Add Tags command for the tag value to be applied" } }, "additionalProperties": false, "default": { "tags": "json", "options": "json=omitempty", "promptForTags": false, "transform": "snakecase", "template": "" }, "description": "Tags and options configured here will be used by the Add Tags command to add tags to struct fields. If promptForTags is true, then user will be prompted for tags and options. By default, json tags are added.", "scope": "resource" }, "go.removeTags": { "type": "object", "properties": { "promptForTags": { "type": "boolean", "default": false, "description": "If true, Go: Remove Tags command will prompt the user to provide tags and options instead of using the configured values" }, "tags": { "type": "string", "default": "json", "description": "Comma separated tags to be used by Go: Remove Tags command" }, "options": { "type": "string", "default": "json=omitempty", "description": "Comma separated tag=options pairs to be used by Go: Remove Tags command" } }, "additionalProperties": false, "default": { "tags": "", "options": "", "promptForTags": false }, "description": "Tags and options configured here will be used by the Remove Tags command to remove tags to struct fields. If promptForTags is true, then user will be prompted for tags and options. By default, all tags and options will be removed.", "scope": "resource" }, "go.playground": { "type": "object", "properties": { "openbrowser": { "type": "boolean", "default": true, "description": "Whether to open the created Go Playground in the default browser" }, "share": { "type": "boolean", "default": true, "description": "Whether to make the created Go Playground shareable" }, "run": { "type": "boolean", "default": true, "description": "Whether to run the created Go Playground after creation" } }, "description": "The flags configured here will be passed through to command `goplay`", "additionalProperties": false, "default": { "openbrowser": true, "share": true, "run": true } }, "go.survey.prompt": { "type": "boolean", "default": true, "description": "Prompt for surveys, including the gopls survey and the Go developer survey." }, "go.editorContextMenuCommands": { "type": "object", "properties": { "toggleTestFile": { "type": "boolean", "default": true, "description": "If true, adds command to toggle between a Go file and its test file to the editor context menu" }, "addTags": { "type": "boolean", "default": true, "description": "If true, adds command to add configured tags from struct fields to the editor context menu" }, "removeTags": { "type": "boolean", "default": true, "description": "If true, adds command to remove configured tags from struct fields to the editor context menu" }, "fillStruct": { "type": "boolean", "default": true, "description": "If true, adds command to fill struct literal with default values to the editor context menu" }, "testAtCursor": { "type": "boolean", "default": false, "description": "If true, adds command to run the test under the cursor to the editor context menu" }, "testFile": { "type": "boolean", "default": true, "description": "If true, adds command to run all tests in the current file to the editor context menu" }, "testPackage": { "type": "boolean", "default": true, "description": "If true, adds command to run all tests in the current package to the editor context menu" }, "generateTestForFunction": { "type": "boolean", "default": true, "description": "If true, adds command to generate unit tests for function under the cursor to the editor context menu" }, "generateTestForFile": { "type": "boolean", "default": true, "description": "If true, adds command to generate unit tests for current file to the editor context menu" }, "generateTestForPackage": { "type": "boolean", "default": true, "description": "If true, adds command to generate unit tests for current package to the editor context menu" }, "addImport": { "type": "boolean", "default": true, "description": "If true, adds command to import a package to the editor context menu" }, "testCoverage": { "type": "boolean", "default": true, "description": "If true, adds command to run test coverage to the editor context menu" }, "playground": { "type": "boolean", "default": true, "description": "If true, adds command to upload the current file or selection to the Go Playground" }, "debugTestAtCursor": { "type": "boolean", "default": false, "description": "If true, adds command to debug the test under the cursor to the editor context menu" }, "benchmarkAtCursor": { "type": "boolean", "default": false, "description": "If true, adds command to benchmark the test under the cursor to the editor context menu" } }, "additionalProperties": false, "default": { "toggleTestFile": true, "addTags": true, "removeTags": false, "fillStruct": false, "testAtCursor": true, "testFile": false, "testPackage": false, "generateTestForFunction": true, "generateTestForFile": false, "generateTestForPackage": false, "addImport": true, "testCoverage": true, "playground": true, "debugTestAtCursor": true, "benchmarkAtCursor": false }, "description": "Experimental Feature: Enable/Disable entries from the context menu in the editor.", "scope": "resource" }, "go.delveConfig": { "type": "object", "properties": { "dlvLoadConfig": { "type": "object", "properties": { "followPointers": { "type": "boolean", "description": "FollowPointers requests pointers to be automatically dereferenced", "default": true }, "maxVariableRecurse": { "type": "number", "description": "MaxVariableRecurse is how far to recurse when evaluating nested types", "default": 1 }, "maxStringLen": { "type": "number", "description": "MaxStringLen is the maximum number of bytes read from a string", "default": 64 }, "maxArrayValues": { "type": "number", "description": "MaxArrayValues is the maximum number of elements read from an array, a slice or a map", "default": 64 }, "maxStructFields": { "type": "number", "description": "MaxStructFields is the maximum number of fields read from a struct, -1 will read all fields", "default": -1 } }, "description": "LoadConfig describes to delve, how to load values from target's memory. Ignored by 'dlv-dap'.", "default": { "followPointers": true, "maxVariableRecurse": 1, "maxStringLen": 64, "maxArrayValues": 64, "maxStructFields": -1 } }, "apiVersion": { "type": "number", "enum": [ 1, 2 ], "description": "Delve Api Version to use. Default value is 2. This applies only when using the 'legacy' debug adapter.", "default": 2 }, "showGlobalVariables": { "type": "boolean", "description": "Boolean value to indicate whether global package variables should be shown in the variables pane or not.", "default": false }, "showRegisters": { "type": "boolean", "default": false, "description": "Boolean value to indicate whether register variables should be shown in the variables pane or not." }, "hideSystemGoroutines": { "type": "boolean", "default": false, "description": "Boolean value to indicate whether system goroutines should be hidden from call stack view." }, "showLog": { "type": "boolean", "description": "Show log output from the delve debugger. Maps to dlv's `--log` flag.", "default": false }, "logOutput": { "type": "string", "enum": [ "debugger", "gdbwire", "lldbout", "debuglineerr", "rpc", "dap" ], "description": "Comma separated list of components that should produce debug output. Maps to dlv's `--log-output` flag. Check `dlv log` for details.", "default": "debugger" }, "debugAdapter": { "type": "string", "enum": [ "legacy", "dlv-dap" ], "description": "Select which debug adapter to use by default. This is also used for choosing which debug adapter to use when no launch.json is present and with codelenses.", "default": "dlv-dap" }, "dlvFlags": { "type": "array", "description": "Extra flags for `dlv`. See `dlv help` for the full list of supported. Flags such as `--log-output`, `--log`, `--log-dest`, `--api-version`, `--output`, `--backend` already have corresponding properties in the debug configuration, and flags such as `--listen` and `--headless` are used internally. If they are specified in `dlvFlags`, they may be ignored or cause an error.", "items": { "type": "string" }, "default": [] }, "substitutePath": { "type": "array", "items": { "type": "object", "properties": { "from": { "type": "string", "description": "The absolute local path to be replaced when passing paths to the debugger", "default": "" }, "to": { "type": "string", "description": "The absolute remote path to be replaced when passing paths back to the client", "default": "" } } }, "description": "An array of mappings from a local path to the remote path that is used by the debuggee. The debug adapter will replace the local path with the remote path in all of the calls. Overriden by `remotePath` (in attach request).", "default": [] } }, "default": {}, "description": "Delve settings that applies to all debugging sessions. Debug configuration in the launch.json file will override these values.", "scope": "resource" }, "go.alternateTools": { "type": "object", "default": {}, "description": "Alternate tools or alternate paths for the same tools used by the Go extension. Provide either absolute path or the name of the binary in GOPATH/bin, GOROOT/bin or PATH. Useful when you want to use wrapper script for the Go tools.", "scope": "resource", "properties": { "go": { "type": "string", "default": "go", "description": "Alternate tool to use instead of the go binary or alternate path to use for the go binary." }, "gopls": { "type": "string", "default": "gopls", "description": "Alternate tool to use instead of the gopls binary or alternate path to use for the gopls binary." }, "dlv": { "type": "string", "default": "dlv", "description": "Alternate tool to use instead of the dlv binary or alternate path to use for the dlv binary." }, "customFormatter": { "type": "string", "default": "", "markdownDescription": "Custom formatter to use instead of the language server. This should be used with the `custom` option in `#go.formatTool#`." } }, "additionalProperties": true }, "go.tasks.provideDefault": { "default": true, "description": "enable the default go build/test task provider.", "scope": "window", "type": "boolean" }, "go.terminal.activateEnvironment": { "default": true, "description": "Apply the Go & PATH environment variables used by the extension to all integrated terminals.", "scope": "resource", "type": "boolean" }, "gopls": { "type": "object", "markdownDescription": "Configure the default Go language server ('gopls'). In most cases, configuring this section is unnecessary. See [the documentation](https://github.com/golang/tools/blob/master/gopls/doc/settings.md) for all available settings.", "scope": "resource", "properties": { "build.buildFlags": { "type": "array", "markdownDescription": "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\nIf unspecified, values of `go.buildFlags, go.buildTags` will be propagated.\n", "default": [], "scope": "resource" }, "build.directoryFilters": { "type": "array", "markdownDescription": "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", "default": [ "-**/node_modules" ], "scope": "resource" }, "build.env": { "type": "object", "markdownDescription": "env adds environment variables to external commands run by `gopls`, most notably `go list`.\n", "scope": "resource" }, "build.expandWorkspaceToModule": { "type": "boolean", "markdownDescription": "(Experimental) expandWorkspaceToModule determines which packages are considered\n\"workspace packages\" when the workspace is using modules.\n\nWorkspace packages affect the scope of workspace-wide operations. Notably,\ngopls diagnoses all packages considered to be part of the workspace after\nevery keystroke, so by setting \"ExpandWorkspaceToModule\" to false, and\nopening a nested workspace directory, you can reduce the amount of work\ngopls has to do to keep your workspace up to date.\n", "default": true, "scope": "resource" }, "build.memoryMode": { "type": "string", "markdownDescription": "(Experimental) obsolete, no effect\n", "default": "", "scope": "resource" }, "build.standaloneTags": { "type": "array", "markdownDescription": "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", "default": [ "ignore" ], "scope": "resource" }, "build.templateExtensions": { "type": "array", "markdownDescription": "templateExtensions gives the extensions of file names that are treated\nas template files. (The extension\nis the part of the file name after the final dot.)\n", "default": [], "scope": "resource" }, "formatting.gofumpt": { "type": "boolean", "markdownDescription": "gofumpt indicates if we should run gofumpt formatting.\n", "default": false, "scope": "resource" }, "formatting.local": { "type": "string", "markdownDescription": "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\nIt is used when tidying imports (during an LSP Organize\nImports request) or when inserting new ones (for example,\nduring completion); an LSP Formatting request merely sorts the\nexisting imports.\n", "default": "", "scope": "resource" }, "ui.codelenses": { "type": "object", "markdownDescription": "codelenses overrides the enabled/disabled state of each of gopls'\nsources of [Code Lenses](codelenses.md).\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", "scope": "resource", "properties": { "gc_details": { "type": "boolean", "markdownDescription": "`\"gc_details\"`: Toggle display of Go compiler optimization decisions\n\nThis codelens source causes the `package` declaration of\neach file to be annotated with a command to toggle the\nstate of the per-session variable that controls whether\noptimization decisions from the Go compiler (formerly known\nas \"gc\") should be displayed as diagnostics.\n\nOptimization decisions include:\n- whether a variable escapes, and how escape is inferred;\n- whether a nil-pointer check is implied or eliminated;\n- whether a function can be inlined.\n\nTODO(adonovan): this source is off by default because the\nannotation is annoying and because VS Code has a separate\n\"Toggle gc details\" command. Replace it with a Code Action\n(\"Source action...\").\n", "default": false }, "generate": { "type": "boolean", "markdownDescription": "`\"generate\"`: Run `go generate`\n\nThis codelens source annotates any `//go:generate` comments\nwith commands to run `go generate` in this directory, on\nall directories recursively beneath this one.\n\nSee [Generating code](https://go.dev/blog/generate) for\nmore details.\n", "default": true }, "regenerate_cgo": { "type": "boolean", "markdownDescription": "`\"regenerate_cgo\"`: Re-generate cgo declarations\n\nThis codelens source annotates an `import \"C\"` declaration\nwith a command to re-run the [cgo\ncommand](https://pkg.go.dev/cmd/cgo) to regenerate the\ncorresponding Go declarations.\n\nUse this after editing the C code in comments attached to\nthe import, or in C header files included by it.\n", "default": true }, "run_govulncheck": { "type": "boolean", "markdownDescription": "`\"run_govulncheck\"`: Run govulncheck (legacy)\n\nThis codelens source annotates the `module` directive in a go.mod file\nwith a command to run Govulncheck asynchronously.\n\n[Govulncheck](https://go.dev/blog/vuln) is a static analysis tool that\ncomputes the set of functions reachable within your application, including\ndependencies; queries a database of known security vulnerabilities; and\nreports any potential problems it finds.\n", "default": false }, "test": { "type": "boolean", "markdownDescription": "`\"test\"`: Run tests and benchmarks\n\nThis codelens source annotates each `Test` and `Benchmark`\nfunction in a `*_test.go` file with a command to run it.\n\nThis source is off by default because VS Code has\na client-side custom UI for testing, and because progress\nnotifications are not a great UX for streamed test output.\nSee:\n- golang/go#67400 for a discussion of this feature.\n- https://github.com/joaotavora/eglot/discussions/1402\n for an alternative approach.\n", "default": false }, "tidy": { "type": "boolean", "markdownDescription": "`\"tidy\"`: Tidy go.mod file\n\nThis codelens source annotates the `module` directive in a\ngo.mod file with a command to run [`go mod\ntidy`](https://go.dev/ref/mod#go-mod-tidy), which ensures\nthat the go.mod file matches the source code in the module.\n", "default": true }, "upgrade_dependency": { "type": "boolean", "markdownDescription": "`\"upgrade_dependency\"`: Update dependencies\n\nThis codelens source annotates the `module` directive in a\ngo.mod file with commands to:\n\n- check for available upgrades,\n- upgrade direct dependencies, and\n- upgrade all dependencies transitively.\n", "default": true }, "vendor": { "type": "boolean", "markdownDescription": "`\"vendor\"`: Update vendor directory\n\nThis codelens source annotates the `module` directive in a\ngo.mod file with a command to run [`go mod\nvendor`](https://go.dev/ref/mod#go-mod-vendor), which\ncreates or updates the directory named `vendor` in the\nmodule root so that it contains an up-to-date copy of all\nnecessary package dependencies.\n", "default": true }, "vulncheck": { "type": "boolean", "markdownDescription": "`\"vulncheck\"`: Run govulncheck\n\nThis codelens source annotates the `module` directive in a go.mod file\nwith a command to run govulncheck synchronously.\n\n[Govulncheck](https://go.dev/blog/vuln) is a static analysis tool that\ncomputes the set of functions reachable within your application, including\ndependencies; queries a database of known security vulnerabilities; and\nreports any potential problems it finds.\n", "default": false } } }, "ui.completion.completeFunctionCalls": { "type": "boolean", "markdownDescription": "completeFunctionCalls enables function call completion.\n\nWhen completing a statement, or when a function return type matches the\nexpected of the expression being completed, completion may suggest call\nexpressions (i.e. may include parentheses).\n", "default": true, "scope": "resource" }, "ui.completion.completionBudget": { "type": "string", "markdownDescription": "(For Debugging) 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", "scope": "resource" }, "ui.completion.experimentalPostfixCompletions": { "type": "boolean", "markdownDescription": "(Experimental) experimentalPostfixCompletions enables artificial method snippets\nsuch as \"someSlice.sort!\".\n", "default": true, "scope": "resource" }, "ui.completion.matcher": { "type": "string", "markdownDescription": "(Advanced) matcher sets the algorithm that is used when calculating completion\ncandidates.\n", "enum": [ "CaseInsensitive", "CaseSensitive", "Fuzzy" ], "markdownEnumDescriptions": [ "", "", "" ], "default": "Fuzzy", "scope": "resource" }, "ui.completion.usePlaceholders": { "type": "boolean", "markdownDescription": "placeholders enables placeholders for function parameters or struct\nfields in completion responses.\n", "default": false, "scope": "resource" }, "ui.diagnostic.analyses": { "type": "object", "markdownDescription": "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 \"unusedvariable\": true // Enable the unusedvariable analyzer.\n}\n...\n```\n", "scope": "resource", "properties": { "appends": { "type": "boolean", "markdownDescription": "check for missing values after append\n\nThis checker reports calls to append that pass\nno values to be appended to the slice.\n\n\ts := []string{\"a\", \"b\", \"c\"}\n\t_ = append(s)\n\nSuch calls are always no-ops and often indicate an\nunderlying mistake.", "default": true }, "asmdecl": { "type": "boolean", "markdownDescription": "report mismatches between assembly files and Go declarations", "default": true }, "assign": { "type": "boolean", "markdownDescription": "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.", "default": true }, "atomic": { "type": "boolean", "markdownDescription": "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.", "default": true }, "atomicalign": { "type": "boolean", "markdownDescription": "check for non-64-bits-aligned arguments to sync/atomic functions", "default": true }, "bools": { "type": "boolean", "markdownDescription": "check for common mistakes involving boolean operators", "default": true }, "buildtag": { "type": "boolean", "markdownDescription": "check //go:build and // +build directives", "default": true }, "cgocall": { "type": "boolean", "markdownDescription": "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.", "default": true }, "composites": { "type": "boolean", "markdownDescription": "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", "default": true }, "copylocks": { "type": "boolean", "markdownDescription": "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.", "default": true }, "deepequalerrors": { "type": "boolean", "markdownDescription": "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.", "default": true }, "defers": { "type": "boolean", "markdownDescription": "report common mistakes in defer statements\n\nThe defers analyzer reports a diagnostic when a defer statement would\nresult in a non-deferred call to time.Since, as experience has shown\nthat this is nearly always a mistake.\n\nFor example:\n\n\tstart := time.Now()\n\t...\n\tdefer recordLatency(time.Since(start)) // error: call to time.Since is not deferred\n\nThe correct code is:\n\n\tdefer func() { recordLatency(time.Since(start)) }()", "default": true }, "deprecated": { "type": "boolean", "markdownDescription": "check for use of deprecated identifiers\n\nThe deprecated analyzer looks for deprecated symbols and package\nimports.\n\nSee https://go.dev/wiki/Deprecated to learn about Go's convention\nfor documenting and signaling deprecated identifiers.", "default": true }, "directive": { "type": "boolean", "markdownDescription": "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", "default": true }, "embed": { "type": "boolean", "markdownDescription": "check //go:embed directive usage\n\nThis analyzer checks that the embed package is imported if //go:embed\ndirectives are present, providing a suggested fix to add the import if\nit is missing.\n\nThis analyzer also checks that //go:embed directives precede the\ndeclaration of a single variable.", "default": true }, "errorsas": { "type": "boolean", "markdownDescription": "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.", "default": true }, "fillreturns": { "type": "boolean", "markdownDescription": "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\n\tfunc m() (int, string, *bool, error) {\n\t\treturn\n\t}\n\nwill turn into\n\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.", "default": true }, "framepointer": { "type": "boolean", "markdownDescription": "report assembly that clobbers the frame pointer before saving it", "default": true }, "httpresponse": { "type": "boolean", "markdownDescription": "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.", "default": true }, "ifaceassert": { "type": "boolean", "markdownDescription": "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.", "default": true }, "infertypeargs": { "type": "boolean", "markdownDescription": "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", "default": true }, "loopclosure": { "type": "boolean", "markdownDescription": "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\nNote: An iteration variable can only outlive a loop iteration in Go versions <=1.21.\nIn Go 1.22 and later, the loop variable lifetimes changed to create a new\niteration variable per loop iteration. (See go.dev/issue/60078.)\n\nIn this example, all the deferred functions run after the loop has\ncompleted, so all observe the final value of v [ 0", "group": "inline" }, { "command": "go.workspace.resetEnv", "when": "viewItem =~ /go:explorer:env/ && workspaceFolderCount > 0" } ] }, "views": { "explorer": [ { "id": "go.explorer", "name": "go", "icon": "media/go-logo-white.svg", "when": "go.showExplorer" } ], "test": [ { "id": "go.test.profile", "name": "Profiles", "contextualTitle": "Go", "icon": "$(graph)", "when": "go.hasProfiles" } ] }, "taskDefinitions": [ { "type": "go", "required": [ "command" ], "properties": { "label": { "type": "string", "description": "the name of go task" }, "command": { "type": "string", "description": "go command to run", "enum": [ "build", "test" ], "enumDescriptions": [ "go build", "go test" ], "default": "build" }, "args": { "type": "array", "description": "additional arguments to pass to the go command (including the build target)", "items": { "type": "string" } }, "options": { "type": "object", "description": "additional command options", "properties": { "cwd": { "type": "string", "description": "the current working directory of the executed program or script. If omitted Code's current workspace root is used." }, "env": { "type": "object", "markdownDescription": "Environment variables in the format of \"name\": \"value\"." } } } } } ] } }ØA —Eoúô