| { |
| "name": "go", |
| "displayName": "Go", |
| "version": "0.48.0-dev", |
| "publisher": "golang", |
| "description": "Rich Go language support for Visual Studio Code", |
| "author": { |
| "name": "Go Team at Google" |
| }, |
| "license": "MIT", |
| "icon": "media/go-logo-blue.png", |
| "categories": [ |
| "Programming Languages", |
| "Snippets", |
| "Linters", |
| "Debuggers", |
| "Formatters", |
| "Testing" |
| ], |
| "galleryBanner": { |
| "color": "#F2F2F2", |
| "theme": "light" |
| }, |
| "private": true, |
| "repository": { |
| "type": "git", |
| "url": "https://github.com/golang/vscode-go" |
| }, |
| "bugs": { |
| "url": "https://github.com/golang/vscode-go/issues" |
| }, |
| "keywords": [ |
| "multi-root ready", |
| "golang", |
| "gopls" |
| ], |
| "scripts": { |
| "clean": "rm -rf ./dist/* && rm -rf ./out/* && rm -rf ./bin/* && rm *.vsix", |
| "package": "cp ../README.md ./README.md && npx vsce package --baseContentUrl https://github.com/golang/vscode-go/raw/HEAD --baseImagesUrl https://github.com/golang/vscode-go/raw/HEAD", |
| "vscode:prepublish": "npm run compile", |
| "bundle": "esbuild src/goMain.ts debugAdapter=src/debugAdapter/goDebug.ts --bundle --outdir=dist --external:vscode --format=cjs --platform=node", |
| "bundle-dev": "npm run bundle -- --sourcemap", |
| "bundle-watch": "npm run bundle -- --sourcemap --watch", |
| "test-compile": "tsc -p ./", |
| "compile": "npm run bundle", |
| "watch": "tsc -watch -p ./", |
| "test": "npm run test-compile && node ./out/test/runTest.js", |
| "lint": "gts lint src test", |
| "fix-lint": "gts fix src test", |
| "unit-test": "npm run test-compile && node ./node_modules/mocha/bin/_mocha -u tdd --timeout 5000 ./out/test/unit", |
| "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"" |
| }, |
| "extensionDependencies": [], |
| "dependencies": { |
| "diff": "4.0.2", |
| "glob": "7.1.7", |
| "json-rpc2": "2.0.0", |
| "moment": "2.29.4", |
| "node-fetch": "2.7.0", |
| "semver": "7.5.4", |
| "tree-kill": "file:third_party/tree-kill", |
| "vscode-debugadapter": "1.45.0", |
| "vscode-debugprotocol": "1.45.0", |
| "vscode-languageclient": "8.1.0", |
| "vscode-languageserver-protocol": "3.17.3", |
| "vscode-uri": "3.0.3" |
| }, |
| "devDependencies": { |
| "@types/adm-zip": "0.4.33", |
| "@types/fs-extra": "8.1.1", |
| "@types/glob": "7.1.3", |
| "@types/mocha": "7.0.2", |
| "@types/node": "13.13.46", |
| "@types/node-fetch": "2.6.9", |
| "@types/semver": "7.3.4", |
| "@types/sinon": "9.0.11", |
| "@types/vscode": "1.90.0", |
| "@vscode/debugadapter-testsupport": "1.68.0", |
| "@vscode/test-electron": "2.5.2", |
| "@vscode/vsce": "2.23.0", |
| "adm-zip": "0.4.16", |
| "esbuild": "0.17.10", |
| "fs-extra": "9.1.0", |
| "get-port": "5.1.1", |
| "gts": "4.0.0", |
| "js-green-licenses": "4.0.0", |
| "mocha": "9.2.2", |
| "prettier": "2.2.1", |
| "sinon": "9.2.4", |
| "typescript": "4.6.4", |
| "yarn": "1.22.22" |
| }, |
| "engines": { |
| "vscode": "^1.90.0", |
| "node": ">=16.14.2" |
| }, |
| "activationEvents": [ |
| "onLanguage:go", |
| "onLanguage:go.sum", |
| "onLanguage:gotmpl", |
| "onLanguage:go.asm", |
| "onDebugInitialConfigurations", |
| "onDebugResolve:go", |
| "onWebviewPanel:welcomeGo" |
| ], |
| "main": "./dist/goMain.js", |
| "capabilities": { |
| "virtualWorkspaces": false, |
| "untrustedWorkspaces": { |
| "supported": "limited", |
| "restrictedConfigurations": [ |
| "go.alternateTools", |
| "go.gopath", |
| "go.goroot", |
| "go.inferGopath", |
| "go.toolsGopath", |
| "go.toolsEnvVars", |
| "go.toolsManagement.go" |
| ] |
| } |
| }, |
| "contributes": { |
| "languages": [ |
| { |
| "id": "go", |
| "extensions": [ |
| ".go" |
| ], |
| "aliases": [ |
| "Go" |
| ] |
| }, |
| { |
| "id": "go.asm", |
| "extensions": [ |
| ".s" |
| ], |
| "aliases": [ |
| "Go Assembly" |
| ] |
| }, |
| { |
| "id": "go.mod", |
| "filenames": [ |
| "go.mod" |
| ], |
| "aliases": [ |
| "Go Module File" |
| ], |
| "configuration": "./languages/go.mod.language-configuration.json" |
| }, |
| { |
| "id": "go.work", |
| "filenames": [ |
| "go.work" |
| ], |
| "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 compiler optimization details", |
| "description": "Toggle the per-package flag that causes compiler optimization details to be reported as diagnostics" |
| }, |
| { |
| "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 (via gopls)" |
| }, |
| { |
| "command": "go.remove.tags", |
| "title": "Go: Remove Tags From Struct Fields", |
| "description": "Remove tags configured in go.removeTags setting from selected struct using gomodifytags (via gopls)" |
| }, |
| { |
| "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 interprets 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=<host>:<port>\" 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=<host>:<port>\" 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=<host>:<port>\" 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=<host>:<port>\" 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=<host>:<port>\" 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=<host>:<port>\" 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=<host>:<port>\" 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=<host>:<port>\" 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. Overridden 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", |
| "golangci-lint-v2", |
| "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. (Deprecated due to the lack of generics support)", |
| "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. Overridden 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" |
| }, |
| "build.workspaceFiles": { |
| "type": "array", |
| "markdownDescription": "workspaceFiles configures the set of globs that match files defining the\nlogical build of the current workspace. Any on-disk changes to any files\nmatching a glob specified here will trigger a reload of the workspace.\n\nThis setting need only be customized in environments with a custom\nGOPACKAGESDRIVER.\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 }\n...\n}\n```\n", |
| "scope": "resource", |
| "properties": { |
| "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": "(Experimental) `\"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": "(Experimental) `\"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": { |
| "QF1001": { |
| "type": "boolean", |
| "markdownDescription": "Apply De Morgan's law\n\nAvailable since\n 2021.1\n", |
| "default": false |
| }, |
| "QF1002": { |
| "type": "boolean", |
| "markdownDescription": "Convert untagged switch to tagged switch\n\nAn untagged switch that compares a single variable against a series of\nvalues can be replaced with a tagged switch.\n\nBefore:\n\n switch {\n case x == 1 || x == 2, x == 3:\n ...\n case x == 4:\n ...\n default:\n ...\n }\n\nAfter:\n\n switch x {\n case 1, 2, 3:\n ...\n case 4:\n ...\n default:\n ...\n }\n\nAvailable since\n 2021.1\n", |
| "default": true |
| }, |
| "QF1003": { |
| "type": "boolean", |
| "markdownDescription": "Convert if/else-if chain to tagged switch\n\nA series of if/else-if checks comparing the same variable against\nvalues can be replaced with a tagged switch.\n\nBefore:\n\n if x == 1 || x == 2 {\n ...\n } else if x == 3 {\n ...\n } else {\n ...\n }\n\nAfter:\n\n switch x {\n case 1, 2:\n ...\n case 3:\n ...\n default:\n ...\n }\n\nAvailable since\n 2021.1\n", |
| "default": true |
| }, |
| "QF1004": { |
| "type": "boolean", |
| "markdownDescription": "Use strings.ReplaceAll instead of strings.Replace with n == -1\n\nAvailable since\n 2021.1\n", |
| "default": true |
| }, |
| "QF1005": { |
| "type": "boolean", |
| "markdownDescription": "Expand call to math.Pow\n\nSome uses of math.Pow can be simplified to basic multiplication.\n\nBefore:\n\n math.Pow(x, 2)\n\nAfter:\n\n x * x\n\nAvailable since\n 2021.1\n", |
| "default": false |
| }, |
| "QF1006": { |
| "type": "boolean", |
| "markdownDescription": "Lift if+break into loop condition\n\nBefore:\n\n for {\n if done {\n break\n }\n ...\n }\n\nAfter:\n\n for !done {\n ...\n }\n\nAvailable since\n 2021.1\n", |
| "default": false |
| }, |
| "QF1007": { |
| "type": "boolean", |
| "markdownDescription": "Merge conditional assignment into variable declaration\n\nBefore:\n\n x := false\n if someCondition {\n x = true\n }\n\nAfter:\n\n x := someCondition\n\nAvailable since\n 2021.1\n", |
| "default": false |
| }, |
| "QF1008": { |
| "type": "boolean", |
| "markdownDescription": "Omit embedded fields from selector expression\n\nAvailable since\n 2021.1\n", |
| "default": false |
| }, |
| "QF1009": { |
| "type": "boolean", |
| "markdownDescription": "Use time.Time.Equal instead of == operator\n\nAvailable since\n 2021.1\n", |
| "default": true |
| }, |
| "QF1010": { |
| "type": "boolean", |
| "markdownDescription": "Convert slice of bytes to string when printing it\n\nAvailable since\n 2021.1\n", |
| "default": true |
| }, |
| "QF1011": { |
| "type": "boolean", |
| "markdownDescription": "Omit redundant type from variable declaration\n\nAvailable since\n 2021.1\n", |
| "default": false |
| }, |
| "QF1012": { |
| "type": "boolean", |
| "markdownDescription": "Use fmt.Fprintf(x, ...) instead of x.Write(fmt.Sprintf(...))\n\nAvailable since\n 2022.1\n", |
| "default": true |
| }, |
| "S1000": { |
| "type": "boolean", |
| "markdownDescription": "Use plain channel send or receive instead of single-case select\n\nSelect statements with a single case can be replaced with a simple\nsend or receive.\n\nBefore:\n\n select {\n case x := <-ch:\n fmt.Println(x)\n }\n\nAfter:\n\n x := <-ch\n fmt.Println(x)\n\nAvailable since\n 2017.1\n", |
| "default": true |
| }, |
| "S1001": { |
| "type": "boolean", |
| "markdownDescription": "Replace for loop with call to copy\n\nUse copy() for copying elements from one slice to another. For\narrays of identical size, you can use simple assignment.\n\nBefore:\n\n for i, x := range src {\n dst[i] = x\n }\n\nAfter:\n\n copy(dst, src)\n\nAvailable since\n 2017.1\n", |
| "default": true |
| }, |
| "S1002": { |
| "type": "boolean", |
| "markdownDescription": "Omit comparison with boolean constant\n\nBefore:\n\n if x == true {}\n\nAfter:\n\n if x {}\n\nAvailable since\n 2017.1\n", |
| "default": false |
| }, |
| "S1003": { |
| "type": "boolean", |
| "markdownDescription": "Replace call to strings.Index with strings.Contains\n\nBefore:\n\n if strings.Index(x, y) != -1 {}\n\nAfter:\n\n if strings.Contains(x, y) {}\n\nAvailable since\n 2017.1\n", |
| "default": true |
| }, |
| "S1004": { |
| "type": "boolean", |
| "markdownDescription": "Replace call to bytes.Compare with bytes.Equal\n\nBefore:\n\n if bytes.Compare(x, y) == 0 {}\n\nAfter:\n\n if bytes.Equal(x, y) {}\n\nAvailable since\n 2017.1\n", |
| "default": true |
| }, |
| "S1005": { |
| "type": "boolean", |
| "markdownDescription": "Drop unnecessary use of the blank identifier\n\nIn many cases, assigning to the blank identifier is unnecessary.\n\nBefore:\n\n for _ = range s {}\n x, _ = someMap[key]\n _ = <-ch\n\nAfter:\n\n for range s{}\n x = someMap[key]\n <-ch\n\nAvailable since\n 2017.1\n", |
| "default": false |
| }, |
| "S1006": { |
| "type": "boolean", |
| "markdownDescription": "Use 'for { ... }' for infinite loops\n\nFor infinite loops, using for { ... } is the most idiomatic choice.\n\nAvailable since\n 2017.1\n", |
| "default": false |
| }, |
| "S1007": { |
| "type": "boolean", |
| "markdownDescription": "Simplify regular expression by using raw string literal\n\nRaw string literals use backticks instead of quotation marks and do not support\nany escape sequences. This means that the backslash can be used\nfreely, without the need of escaping.\n\nSince regular expressions have their own escape sequences, raw strings\ncan improve their readability.\n\nBefore:\n\n regexp.Compile(\"\\\\A(\\\\w+) profile: total \\\\d+\\\\n\\\\z\")\n\nAfter:\n\n regexp.Compile(`\\A(\\w+) profile: total \\d+\\n\\z`)\n\nAvailable since\n 2017.1\n", |
| "default": true |
| }, |
| "S1008": { |
| "type": "boolean", |
| "markdownDescription": "Simplify returning boolean expression\n\nBefore:\n\n if <expr> {\n return true\n }\n return false\n\nAfter:\n\n return <expr>\n\nAvailable since\n 2017.1\n", |
| "default": false |
| }, |
| "S1009": { |
| "type": "boolean", |
| "markdownDescription": "Omit redundant nil check on slices, maps, and channels\n\nThe len function is defined for all slices, maps, and\nchannels, even nil ones, which have a length of zero. It is not necessary to\ncheck for nil before checking that their length is not zero.\n\nBefore:\n\n if x != nil && len(x) != 0 {}\n\nAfter:\n\n if len(x) != 0 {}\n\nAvailable since\n 2017.1\n", |
| "default": true |
| }, |
| "S1010": { |
| "type": "boolean", |
| "markdownDescription": "Omit default slice index\n\nWhen slicing, the second index defaults to the length of the value,\nmaking s[n:len(s)] and s[n:] equivalent.\n\nAvailable since\n 2017.1\n", |
| "default": true |
| }, |
| "S1011": { |
| "type": "boolean", |
| "markdownDescription": "Use a single append to concatenate two slices\n\nBefore:\n\n for _, e := range y {\n x = append(x, e)\n }\n \n for i := range y {\n x = append(x, y[i])\n }\n \n for i := range y {\n v := y[i]\n x = append(x, v)\n }\n\nAfter:\n\n x = append(x, y...)\n x = append(x, y...)\n x = append(x, y...)\n\nAvailable since\n 2017.1\n", |
| "default": false |
| }, |
| "S1012": { |
| "type": "boolean", |
| "markdownDescription": "Replace time.Now().Sub(x) with time.Since(x)\n\nThe time.Since helper has the same effect as using time.Now().Sub(x)\nbut is easier to read.\n\nBefore:\n\n time.Now().Sub(x)\n\nAfter:\n\n time.Since(x)\n\nAvailable since\n 2017.1\n", |
| "default": true |
| }, |
| "S1016": { |
| "type": "boolean", |
| "markdownDescription": "Use a type conversion instead of manually copying struct fields\n\nTwo struct types with identical fields can be converted between each\nother. In older versions of Go, the fields had to have identical\nstruct tags. Since Go 1.8, however, struct tags are ignored during\nconversions. It is thus not necessary to manually copy every field\nindividually.\n\nBefore:\n\n var x T1\n y := T2{\n Field1: x.Field1,\n Field2: x.Field2,\n }\n\nAfter:\n\n var x T1\n y := T2(x)\n\nAvailable since\n 2017.1\n", |
| "default": false |
| }, |
| "S1017": { |
| "type": "boolean", |
| "markdownDescription": "Replace manual trimming with strings.TrimPrefix\n\nInstead of using strings.HasPrefix and manual slicing, use the\nstrings.TrimPrefix function. If the string doesn't start with the\nprefix, the original string will be returned. Using strings.TrimPrefix\nreduces complexity, and avoids common bugs, such as off-by-one\nmistakes.\n\nBefore:\n\n if strings.HasPrefix(str, prefix) {\n str = str[len(prefix):]\n }\n\nAfter:\n\n str = strings.TrimPrefix(str, prefix)\n\nAvailable since\n 2017.1\n", |
| "default": true |
| }, |
| "S1018": { |
| "type": "boolean", |
| "markdownDescription": "Use 'copy' for sliding elements\n\ncopy() permits using the same source and destination slice, even with\noverlapping ranges. This makes it ideal for sliding elements in a\nslice.\n\nBefore:\n\n for i := 0; i < n; i++ {\n bs[i] = bs[offset+i]\n }\n\nAfter:\n\n copy(bs[:n], bs[offset:])\n\nAvailable since\n 2017.1\n", |
| "default": true |
| }, |
| "S1019": { |
| "type": "boolean", |
| "markdownDescription": "Simplify 'make' call by omitting redundant arguments\n\nThe 'make' function has default values for the length and capacity\narguments. For channels, the length defaults to zero, and for slices,\nthe capacity defaults to the length.\n\nAvailable since\n 2017.1\n", |
| "default": true |
| }, |
| "S1020": { |
| "type": "boolean", |
| "markdownDescription": "Omit redundant nil check in type assertion\n\nBefore:\n\n if _, ok := i.(T); ok && i != nil {}\n\nAfter:\n\n if _, ok := i.(T); ok {}\n\nAvailable since\n 2017.1\n", |
| "default": true |
| }, |
| "S1021": { |
| "type": "boolean", |
| "markdownDescription": "Merge variable declaration and assignment\n\nBefore:\n\n var x uint\n x = 1\n\nAfter:\n\n var x uint = 1\n\nAvailable since\n 2017.1\n", |
| "default": false |
| }, |
| "S1023": { |
| "type": "boolean", |
| "markdownDescription": "Omit redundant control flow\n\nFunctions that have no return value do not need a return statement as\nthe final statement of the function.\n\nSwitches in Go do not have automatic fallthrough, unlike languages\nlike C. It is not necessary to have a break statement as the final\nstatement in a case block.\n\nAvailable since\n 2017.1\n", |
| "default": true |
| }, |
| "S1024": { |
| "type": "boolean", |
| "markdownDescription": "Replace x.Sub(time.Now()) with time.Until(x)\n\nThe time.Until helper has the same effect as using x.Sub(time.Now())\nbut is easier to read.\n\nBefore:\n\n x.Sub(time.Now())\n\nAfter:\n\n time.Until(x)\n\nAvailable since\n 2017.1\n", |
| "default": true |
| }, |
| "S1025": { |
| "type": "boolean", |
| "markdownDescription": "Don't use fmt.Sprintf(\"%s\", x) unnecessarily\n\nIn many instances, there are easier and more efficient ways of getting\na value's string representation. Whenever a value's underlying type is\na string already, or the type has a String method, they should be used\ndirectly.\n\nGiven the following shared definitions\n\n type T1 string\n type T2 int\n\n func (T2) String() string { return \"Hello, world\" }\n\n var x string\n var y T1\n var z T2\n\nwe can simplify\n\n fmt.Sprintf(\"%s\", x)\n fmt.Sprintf(\"%s\", y)\n fmt.Sprintf(\"%s\", z)\n\nto\n\n x\n string(y)\n z.String()\n\nAvailable since\n 2017.1\n", |
| "default": false |
| }, |
| "S1028": { |
| "type": "boolean", |
| "markdownDescription": "Simplify error construction with fmt.Errorf\n\nBefore:\n\n errors.New(fmt.Sprintf(...))\n\nAfter:\n\n fmt.Errorf(...)\n\nAvailable since\n 2017.1\n", |
| "default": true |
| }, |
| "S1029": { |
| "type": "boolean", |
| "markdownDescription": "Range over the string directly\n\nRanging over a string will yield byte offsets and runes. If the offset\nisn't used, this is functionally equivalent to converting the string\nto a slice of runes and ranging over that. Ranging directly over the\nstring will be more performant, however, as it avoids allocating a new\nslice, the size of which depends on the length of the string.\n\nBefore:\n\n for _, r := range []rune(s) {}\n\nAfter:\n\n for _, r := range s {}\n\nAvailable since\n 2017.1\n", |
| "default": false |
| }, |
| "S1030": { |
| "type": "boolean", |
| "markdownDescription": "Use bytes.Buffer.String or bytes.Buffer.Bytes\n\nbytes.Buffer has both a String and a Bytes method. It is almost never\nnecessary to use string(buf.Bytes()) or []byte(buf.String()) – simply\nuse the other method.\n\nThe only exception to this are map lookups. Due to a compiler optimization,\nm[string(buf.Bytes())] is more efficient than m[buf.String()].\n\nAvailable since\n 2017.1\n", |
| "default": true |
| }, |
| "S1031": { |
| "type": "boolean", |
| "markdownDescription": "Omit redundant nil check around loop\n\nYou can use range on nil slices and maps, the loop will simply never\nexecute. This makes an additional nil check around the loop\nunnecessary.\n\nBefore:\n\n if s != nil {\n for _, x := range s {\n ...\n }\n }\n\nAfter:\n\n for _, x := range s {\n ...\n }\n\nAvailable since\n 2017.1\n", |
| "default": true |
| }, |
| "S1032": { |
| "type": "boolean", |
| "markdownDescription": "Use sort.Ints(x), sort.Float64s(x), and sort.Strings(x)\n\nThe sort.Ints, sort.Float64s and sort.Strings functions are easier to\nread than sort.Sort(sort.IntSlice(x)), sort.Sort(sort.Float64Slice(x))\nand sort.Sort(sort.StringSlice(x)).\n\nBefore:\n\n sort.Sort(sort.StringSlice(x))\n\nAfter:\n\n sort.Strings(x)\n\nAvailable since\n 2019.1\n", |
| "default": true |
| }, |
| "S1033": { |
| "type": "boolean", |
| "markdownDescription": "Unnecessary guard around call to 'delete'\n\nCalling delete on a nil map is a no-op.\n\nAvailable since\n 2019.2\n", |
| "default": true |
| }, |
| "S1034": { |
| "type": "boolean", |
| "markdownDescription": "Use result of type assertion to simplify cases\n\nAvailable since\n 2019.2\n", |
| "default": true |
| }, |
| "S1035": { |
| "type": "boolean", |
| "markdownDescription": "Redundant call to net/http.CanonicalHeaderKey in method call on net/http.Header\n\nThe methods on net/http.Header, namely Add, Del, Get\nand Set, already canonicalize the given header name.\n\nAvailable since\n 2020.1\n", |
| "default": true |
| }, |
| "S1036": { |
| "type": "boolean", |
| "markdownDescription": "Unnecessary guard around map access\n\nWhen accessing a map key that doesn't exist yet, one receives a zero\nvalue. Often, the zero value is a suitable value, for example when\nusing append or doing integer math.\n\nThe following\n\n if _, ok := m[\"foo\"]; ok {\n m[\"foo\"] = append(m[\"foo\"], \"bar\")\n } else {\n m[\"foo\"] = []string{\"bar\"}\n }\n\ncan be simplified to\n\n m[\"foo\"] = append(m[\"foo\"], \"bar\")\n\nand\n\n if _, ok := m2[\"k\"]; ok {\n m2[\"k\"] += 4\n } else {\n m2[\"k\"] = 4\n }\n\ncan be simplified to\n\n m[\"k\"] += 4\n\nAvailable since\n 2020.1\n", |
| "default": true |
| }, |
| "S1037": { |
| "type": "boolean", |
| "markdownDescription": "Elaborate way of sleeping\n\nUsing a select statement with a single case receiving\nfrom the result of time.After is a very elaborate way of sleeping that\ncan much simpler be expressed with a simple call to time.Sleep.\n\nAvailable since\n 2020.1\n", |
| "default": true |
| }, |
| "S1038": { |
| "type": "boolean", |
| "markdownDescription": "Unnecessarily complex way of printing formatted string\n\nInstead of using fmt.Print(fmt.Sprintf(...)), one can use fmt.Printf(...).\n\nAvailable since\n 2020.1\n", |
| "default": true |
| }, |
| "S1039": { |
| "type": "boolean", |
| "markdownDescription": "Unnecessary use of fmt.Sprint\n\nCalling fmt.Sprint with a single string argument is unnecessary\nand identical to using the string directly.\n\nAvailable since\n 2020.1\n", |
| "default": true |
| }, |
| "S1040": { |
| "type": "boolean", |
| "markdownDescription": "Type assertion to current type\n\nThe type assertion x.(SomeInterface), when x already has type\nSomeInterface, can only fail if x is nil. Usually, this is\nleft-over code from when x had a different type and you can safely\ndelete the type assertion. If you want to check that x is not nil,\nconsider being explicit and using an actual if x == nil comparison\ninstead of relying on the type assertion panicking.\n\nAvailable since\n 2021.1\n", |
| "default": true |
| }, |
| "SA1000": { |
| "type": "boolean", |
| "markdownDescription": "Invalid regular expression\n\nAvailable since\n 2017.1\n", |
| "default": false |
| }, |
| "SA1001": { |
| "type": "boolean", |
| "markdownDescription": "Invalid template\n\nAvailable since\n 2017.1\n", |
| "default": true |
| }, |
| "SA1002": { |
| "type": "boolean", |
| "markdownDescription": "Invalid format in time.Parse\n\nAvailable since\n 2017.1\n", |
| "default": false |
| }, |
| "SA1003": { |
| "type": "boolean", |
| "markdownDescription": "Unsupported argument to functions in encoding/binary\n\nThe encoding/binary package can only serialize types with known sizes.\nThis precludes the use of the int and uint types, as their sizes\ndiffer on different architectures. Furthermore, it doesn't support\nserializing maps, channels, strings, or functions.\n\nBefore Go 1.8, bool wasn't supported, either.\n\nAvailable since\n 2017.1\n", |
| "default": false |
| }, |
| "SA1004": { |
| "type": "boolean", |
| "markdownDescription": "Suspiciously small untyped constant in time.Sleep\n\nThe time.Sleep function takes a time.Duration as its only argument.\nDurations are expressed in nanoseconds. Thus, calling time.Sleep(1)\nwill sleep for 1 nanosecond. This is a common source of bugs, as sleep\nfunctions in other languages often accept seconds or milliseconds.\n\nThe time package provides constants such as time.Second to express\nlarge durations. These can be combined with arithmetic to express\narbitrary durations, for example 5 * time.Second for 5 seconds.\n\nIf you truly meant to sleep for a tiny amount of time, use\nn * time.Nanosecond to signal to Staticcheck that you did mean to sleep\nfor some amount of nanoseconds.\n\nAvailable since\n 2017.1\n", |
| "default": true |
| }, |
| "SA1005": { |
| "type": "boolean", |
| "markdownDescription": "Invalid first argument to exec.Command\n\nos/exec runs programs directly (using variants of the fork and exec\nsystem calls on Unix systems). This shouldn't be confused with running\na command in a shell. The shell will allow for features such as input\nredirection, pipes, and general scripting. The shell is also\nresponsible for splitting the user's input into a program name and its\narguments. For example, the equivalent to\n\n ls / /tmp\n\nwould be\n\n exec.Command(\"ls\", \"/\", \"/tmp\")\n\nIf you want to run a command in a shell, consider using something like\nthe following – but be aware that not all systems, particularly\nWindows, will have a /bin/sh program:\n\n exec.Command(\"/bin/sh\", \"-c\", \"ls | grep Awesome\")\n\nAvailable since\n 2017.1\n", |
| "default": true |
| }, |
| "SA1007": { |
| "type": "boolean", |
| "markdownDescription": "Invalid URL in net/url.Parse\n\nAvailable since\n 2017.1\n", |
| "default": false |
| }, |
| "SA1008": { |
| "type": "boolean", |
| "markdownDescription": "Non-canonical key in http.Header map\n\nKeys in http.Header maps are canonical, meaning they follow a specific\ncombination of uppercase and lowercase letters. Methods such as\nhttp.Header.Add and http.Header.Del convert inputs into this canonical\nform before manipulating the map.\n\nWhen manipulating http.Header maps directly, as opposed to using the\nprovided methods, care should be taken to stick to canonical form in\norder to avoid inconsistencies. The following piece of code\ndemonstrates one such inconsistency:\n\n h := http.Header{}\n h[\"etag\"] = []string{\"1234\"}\n h.Add(\"etag\", \"5678\")\n fmt.Println(h)\n\n // Output:\n // map[Etag:[5678] etag:[1234]]\n\nThe easiest way of obtaining the canonical form of a key is to use\nhttp.CanonicalHeaderKey.\n\nAvailable since\n 2017.1\n", |
| "default": true |
| }, |
| "SA1010": { |
| "type": "boolean", |
| "markdownDescription": "(*regexp.Regexp).FindAll called with n == 0, which will always return zero results\n\nIf n >= 0, the function returns at most n matches/submatches. To\nreturn all results, specify a negative number.\n\nAvailable since\n 2017.1\n", |
| "default": false |
| }, |
| "SA1011": { |
| "type": "boolean", |
| "markdownDescription": "Various methods in the 'strings' package expect valid UTF-8, but invalid input is provided\n\nAvailable since\n 2017.1\n", |
| "default": false |
| }, |
| "SA1012": { |
| "type": "boolean", |
| "markdownDescription": "A nil context.Context is being passed to a function, consider using context.TODO instead\n\nAvailable since\n 2017.1\n", |
| "default": true |
| }, |
| "SA1013": { |
| "type": "boolean", |
| "markdownDescription": "io.Seeker.Seek is being called with the whence constant as the first argument, but it should be the second\n\nAvailable since\n 2017.1\n", |
| "default": true |
| }, |
| "SA1014": { |
| "type": "boolean", |
| "markdownDescription": "Non-pointer value passed to Unmarshal or Decode\n\nAvailable since\n 2017.1\n", |
| "default": false |
| }, |
| "SA1015": { |
| "type": "boolean", |
| "markdownDescription": "Using time.Tick in a way that will leak. Consider using time.NewTicker, and only use time.Tick in tests, commands and endless functions\n\nBefore Go 1.23, time.Tickers had to be closed to be able to be garbage\ncollected. Since time.Tick doesn't make it possible to close the underlying\nticker, using it repeatedly would leak memory.\n\nGo 1.23 fixes this by allowing tickers to be collected even if they weren't closed.\n\nAvailable since\n 2017.1\n", |
| "default": false |
| }, |
| "SA1016": { |
| "type": "boolean", |
| "markdownDescription": "Trapping a signal that cannot be trapped\n\nNot all signals can be intercepted by a process. Specifically, on\nUNIX-like systems, the syscall.SIGKILL and syscall.SIGSTOP signals are\nnever passed to the process, but instead handled directly by the\nkernel. It is therefore pointless to try and handle these signals.\n\nAvailable since\n 2017.1\n", |
| "default": true |
| }, |
| "SA1017": { |
| "type": "boolean", |
| "markdownDescription": "Channels used with os/signal.Notify should be buffered\n\nThe os/signal package uses non-blocking channel sends when delivering\nsignals. If the receiving end of the channel isn't ready and the\nchannel is either unbuffered or full, the signal will be dropped. To\navoid missing signals, the channel should be buffered and of the\nappropriate size. For a channel used for notification of just one\nsignal value, a buffer of size 1 is sufficient.\n\nAvailable since\n 2017.1\n", |
| "default": false |
| }, |
| "SA1018": { |
| "type": "boolean", |
| "markdownDescription": "strings.Replace called with n == 0, which does nothing\n\nWith n == 0, zero instances will be replaced. To replace all\ninstances, use a negative number, or use strings.ReplaceAll.\n\nAvailable since\n 2017.1\n", |
| "default": false |
| }, |
| "SA1020": { |
| "type": "boolean", |
| "markdownDescription": "Using an invalid host:port pair with a net.Listen-related function\n\nAvailable since\n 2017.1\n", |
| "default": false |
| }, |
| "SA1021": { |
| "type": "boolean", |
| "markdownDescription": "Using bytes.Equal to compare two net.IP\n\nA net.IP stores an IPv4 or IPv6 address as a slice of bytes. The\nlength of the slice for an IPv4 address, however, can be either 4 or\n16 bytes long, using different ways of representing IPv4 addresses. In\norder to correctly compare two net.IPs, the net.IP.Equal method should\nbe used, as it takes both representations into account.\n\nAvailable since\n 2017.1\n", |
| "default": false |
| }, |
| "SA1023": { |
| "type": "boolean", |
| "markdownDescription": "Modifying the buffer in an io.Writer implementation\n\nWrite must not modify the slice data, even temporarily.\n\nAvailable since\n 2017.1\n", |
| "default": false |
| }, |
| "SA1024": { |
| "type": "boolean", |
| "markdownDescription": "A string cutset contains duplicate characters\n\nThe strings.TrimLeft and strings.TrimRight functions take cutsets, not\nprefixes. A cutset is treated as a set of characters to remove from a\nstring. For example,\n\n strings.TrimLeft(\"42133word\", \"1234\")\n\nwill result in the string \"word\" – any characters that are 1, 2, 3 or\n4 are cut from the left of the string.\n\nIn order to remove one string from another, use strings.TrimPrefix instead.\n\nAvailable since\n 2017.1\n", |
| "default": false |
| }, |
| "SA1025": { |
| "type": "boolean", |
| "markdownDescription": "It is not possible to use (*time.Timer).Reset's return value correctly\n\nAvailable since\n 2019.1\n", |
| "default": false |
| }, |
| "SA1026": { |
| "type": "boolean", |
| "markdownDescription": "Cannot marshal channels or functions\n\nAvailable since\n 2019.2\n", |
| "default": false |
| }, |
| "SA1027": { |
| "type": "boolean", |
| "markdownDescription": "Atomic access to 64-bit variable must be 64-bit aligned\n\nOn ARM, x86-32, and 32-bit MIPS, it is the caller's responsibility to\narrange for 64-bit alignment of 64-bit words accessed atomically. The\nfirst word in a variable or in an allocated struct, array, or slice\ncan be relied upon to be 64-bit aligned.\n\nYou can use the structlayout tool to inspect the alignment of fields\nin a struct.\n\nAvailable since\n 2019.2\n", |
| "default": false |
| }, |
| "SA1028": { |
| "type": "boolean", |
| "markdownDescription": "sort.Slice can only be used on slices\n\nThe first argument of sort.Slice must be a slice.\n\nAvailable since\n 2020.1\n", |
| "default": false |
| }, |
| "SA1029": { |
| "type": "boolean", |
| "markdownDescription": "Inappropriate key in call to context.WithValue\n\nThe provided key must be comparable and should not be\nof type string or any other built-in type to avoid collisions between\npackages using context. Users of WithValue should define their own\ntypes for keys.\n\nTo avoid allocating when assigning to an interface{},\ncontext keys often have concrete type struct{}. Alternatively,\nexported context key variables' static type should be a pointer or\ninterface.\n\nAvailable since\n 2020.1\n", |
| "default": false |
| }, |
| "SA1030": { |
| "type": "boolean", |
| "markdownDescription": "Invalid argument in call to a strconv function\n\nThis check validates the format, number base and bit size arguments of\nthe various parsing and formatting functions in strconv.\n\nAvailable since\n 2021.1\n", |
| "default": false |
| }, |
| "SA1031": { |
| "type": "boolean", |
| "markdownDescription": "Overlapping byte slices passed to an encoder\n\nIn an encoding function of the form Encode(dst, src), dst and\nsrc were found to reference the same memory. This can result in\nsrc bytes being overwritten before they are read, when the encoder\nwrites more than one byte per src byte.\n\nAvailable since\n 2024.1\n", |
| "default": false |
| }, |
| "SA1032": { |
| "type": "boolean", |
| "markdownDescription": "Wrong order of arguments to errors.Is\n\nThe first argument of the function errors.Is is the error\nthat we have and the second argument is the error we're trying to match against.\nFor example:\n\n\tif errors.Is(err, io.EOF) { ... }\n\nThis check detects some cases where the two arguments have been swapped. It\nflags any calls where the first argument is referring to a package-level error\nvariable, such as\n\n\tif errors.Is(io.EOF, err) { /* this is wrong */ }\n\nAvailable since\n 2024.1\n", |
| "default": false |
| }, |
| "SA2001": { |
| "type": "boolean", |
| "markdownDescription": "Empty critical section, did you mean to defer the unlock?\n\nEmpty critical sections of the kind\n\n mu.Lock()\n mu.Unlock()\n\nare very often a typo, and the following was intended instead:\n\n mu.Lock()\n defer mu.Unlock()\n\nDo note that sometimes empty critical sections can be useful, as a\nform of signaling to wait on another goroutine. Many times, there are\nsimpler ways of achieving the same effect. When that isn't the case,\nthe code should be amply commented to avoid confusion. Combining such\ncomments with a //lint:ignore directive can be used to suppress this\nrare false positive.\n\nAvailable since\n 2017.1\n", |
| "default": true |
| }, |
| "SA2002": { |
| "type": "boolean", |
| "markdownDescription": "Called testing.T.FailNow or SkipNow in a goroutine, which isn't allowed\n\nAvailable since\n 2017.1\n", |
| "default": false |
| }, |
| "SA2003": { |
| "type": "boolean", |
| "markdownDescription": "Deferred Lock right after locking, likely meant to defer Unlock instead\n\nAvailable since\n 2017.1\n", |
| "default": false |
| }, |
| "SA3000": { |
| "type": "boolean", |
| "markdownDescription": "TestMain doesn't call os.Exit, hiding test failures\n\nTest executables (and in turn 'go test') exit with a non-zero status\ncode if any tests failed. When specifying your own TestMain function,\nit is your responsibility to arrange for this, by calling os.Exit with\nthe correct code. The correct code is returned by (*testing.M).Run, so\nthe usual way of implementing TestMain is to end it with\nos.Exit(m.Run()).\n\nAvailable since\n 2017.1\n", |
| "default": true |
| }, |
| "SA3001": { |
| "type": "boolean", |
| "markdownDescription": "Assigning to b.N in benchmarks distorts the results\n\nThe testing package dynamically sets b.N to improve the reliability of\nbenchmarks and uses it in computations to determine the duration of a\nsingle operation. Benchmark code must not alter b.N as this would\nfalsify results.\n\nAvailable since\n 2017.1\n", |
| "default": true |
| }, |
| "SA4000": { |
| "type": "boolean", |
| "markdownDescription": "Binary operator has identical expressions on both sides\n\nAvailable since\n 2017.1\n", |
| "default": true |
| }, |
| "SA4001": { |
| "type": "boolean", |
| "markdownDescription": "&*x gets simplified to x, it does not copy x\n\nAvailable since\n 2017.1\n", |
| "default": true |
| }, |
| "SA4003": { |
| "type": "boolean", |
| "markdownDescription": "Comparing unsigned values against negative values is pointless\n\nAvailable since\n 2017.1\n", |
| "default": true |
| }, |
| "SA4004": { |
| "type": "boolean", |
| "markdownDescription": "The loop exits unconditionally after one iteration\n\nAvailable since\n 2017.1\n", |
| "default": true |
| }, |
| "SA4005": { |
| "type": "boolean", |
| "markdownDescription": "Field assignment that will never be observed. Did you mean to use a pointer receiver?\n\nAvailable since\n 2021.1\n", |
| "default": false |
| }, |
| "SA4006": { |
| "type": "boolean", |
| "markdownDescription": "A value assigned to a variable is never read before being overwritten. Forgotten error check or dead code?\n\nAvailable since\n 2017.1\n", |
| "default": false |
| }, |
| "SA4008": { |
| "type": "boolean", |
| "markdownDescription": "The variable in the loop condition never changes, are you incrementing the wrong variable?\n\nFor example:\n\n\tfor i := 0; i < 10; j++ { ... }\n\nThis may also occur when a loop can only execute once because of unconditional\ncontrol flow that terminates the loop. For example, when a loop body contains an\nunconditional break, return, or panic:\n\n\tfunc f() {\n\t\tpanic(\"oops\")\n\t}\n\tfunc g() {\n\t\tfor i := 0; i < 10; i++ {\n\t\t\t// f unconditionally calls panic, which means \"i\" is\n\t\t\t// never incremented.\n\t\t\tf()\n\t\t}\n\t}\n\nAvailable since\n 2017.1\n", |
| "default": false |
| }, |
| "SA4009": { |
| "type": "boolean", |
| "markdownDescription": "A function argument is overwritten before its first use\n\nAvailable since\n 2017.1\n", |
| "default": false |
| }, |
| "SA4010": { |
| "type": "boolean", |
| "markdownDescription": "The result of append will never be observed anywhere\n\nAvailable since\n 2017.1\n", |
| "default": false |
| }, |
| "SA4011": { |
| "type": "boolean", |
| "markdownDescription": "Break statement with no effect. Did you mean to break out of an outer loop?\n\nAvailable since\n 2017.1\n", |
| "default": true |
| }, |
| "SA4012": { |
| "type": "boolean", |
| "markdownDescription": "Comparing a value against NaN even though no value is equal to NaN\n\nAvailable since\n 2017.1\n", |
| "default": false |
| }, |
| "SA4013": { |
| "type": "boolean", |
| "markdownDescription": "Negating a boolean twice (!!b) is the same as writing b. This is either redundant, or a typo.\n\nAvailable since\n 2017.1\n", |
| "default": true |
| }, |
| "SA4014": { |
| "type": "boolean", |
| "markdownDescription": "An if/else if chain has repeated conditions and no side-effects; if the condition didn't match the first time, it won't match the second time, either\n\nAvailable since\n 2017.1\n", |
| "default": true |
| }, |
| "SA4015": { |
| "type": "boolean", |
| "markdownDescription": "Calling functions like math.Ceil on floats converted from integers doesn't do anything useful\n\nAvailable since\n 2017.1\n", |
| "default": false |
| }, |
| "SA4016": { |
| "type": "boolean", |
| "markdownDescription": "Certain bitwise operations, such as x ^ 0, do not do anything useful\n\nAvailable since\n 2017.1\n", |
| "default": true |
| }, |
| "SA4017": { |
| "type": "boolean", |
| "markdownDescription": "Discarding the return values of a function without side effects, making the call pointless\n\nAvailable since\n 2017.1\n", |
| "default": false |
| }, |
| "SA4018": { |
| "type": "boolean", |
| "markdownDescription": "Self-assignment of variables\n\nAvailable since\n 2017.1\n", |
| "default": false |
| }, |
| "SA4019": { |
| "type": "boolean", |
| "markdownDescription": "Multiple, identical build constraints in the same file\n\nAvailable since\n 2017.1\n", |
| "default": true |
| }, |
| "SA4020": { |
| "type": "boolean", |
| "markdownDescription": "Unreachable case clause in a type switch\n\nIn a type switch like the following\n\n type T struct{}\n func (T) Read(b []byte) (int, error) { return 0, nil }\n\n var v any = T{}\n\n switch v.(type) {\n case io.Reader:\n // ...\n case T:\n // unreachable\n }\n\nthe second case clause can never be reached because T implements\nio.Reader and case clauses are evaluated in source order.\n\nAnother example:\n\n type T struct{}\n func (T) Read(b []byte) (int, error) { return 0, nil }\n func (T) Close() error { return nil }\n\n var v any = T{}\n\n switch v.(type) {\n case io.Reader:\n // ...\n case io.ReadCloser:\n // unreachable\n }\n\nEven though T has a Close method and thus implements io.ReadCloser,\nio.Reader will always match first. The method set of io.Reader is a\nsubset of io.ReadCloser. Thus it is impossible to match the second\ncase without matching the first case.\n\n\nStructurally equivalent interfaces\n\nA special case of the previous example are structurally identical\ninterfaces. Given these declarations\n\n type T error\n type V error\n\n func doSomething() error {\n err, ok := doAnotherThing()\n if ok {\n return T(err)\n }\n\n return U(err)\n }\n\nthe following type switch will have an unreachable case clause:\n\n switch doSomething().(type) {\n case T:\n // ...\n case V:\n // unreachable\n }\n\nT will always match before V because they are structurally equivalent\nand therefore doSomething()'s return value implements both.\n\nAvailable since\n 2019.2\n", |
| "default": true |
| }, |
| "SA4022": { |
| "type": "boolean", |
| "markdownDescription": "Comparing the address of a variable against nil\n\nCode such as 'if &x == nil' is meaningless, because taking the address of a variable always yields a non-nil pointer.\n\nAvailable since\n 2020.1\n", |
| "default": true |
| }, |
| "SA4023": { |
| "type": "boolean", |
| "markdownDescription": "Impossible comparison of interface value with untyped nil\n\nUnder the covers, interfaces are implemented as two elements, a\ntype T and a value V. V is a concrete value such as an int,\nstruct or pointer, never an interface itself, and has type T. For\ninstance, if we store the int value 3 in an interface, the\nresulting interface value has, schematically, (T=int, V=3). The\nvalue V is also known as the interface's dynamic value, since a\ngiven interface variable might hold different values V (and\ncorresponding types T) during the execution of the program.\n\nAn interface value is nil only if the V and T are both\nunset, (T=nil, V is not set), In particular, a nil interface will\nalways hold a nil type. If we store a nil pointer of type *int\ninside an interface value, the inner type will be *int regardless\nof the value of the pointer: (T=*int, V=nil). Such an interface\nvalue will therefore be non-nil even when the pointer value V\ninside is nil.\n\nThis situation can be confusing, and arises when a nil value is\nstored inside an interface value such as an error return:\n\n func returnsError() error {\n var p *MyError = nil\n if bad() {\n p = ErrBad\n }\n return p // Will always return a non-nil error.\n }\n\nIf all goes well, the function returns a nil p, so the return\nvalue is an error interface value holding (T=*MyError, V=nil).\nThis means that if the caller compares the returned error to nil,\nit will always look as if there was an error even if nothing bad\nhappened. To return a proper nil error to the caller, the\nfunction must return an explicit nil:\n\n func returnsError() error {\n if bad() {\n return ErrBad\n }\n return nil\n }\n\nIt's a good idea for functions that return errors always to use\nthe error type in their signature (as we did above) rather than a\nconcrete type such as *MyError, to help guarantee the error is\ncreated correctly. As an example, os.Open returns an error even\nthough, if not nil, it's always of concrete type *os.PathError.\n\nSimilar situations to those described here can arise whenever\ninterfaces are used. Just keep in mind that if any concrete value\nhas been stored in the interface, the interface will not be nil.\nFor more information, see The Laws of\nReflection at https://golang.org/doc/articles/laws_of_reflection.html.\n\nThis text has been copied from\nhttps://golang.org/doc/faq#nil_error, licensed under the Creative\nCommons Attribution 3.0 License.\n\nAvailable since\n 2020.2\n", |
| "default": false |
| }, |
| "SA4024": { |
| "type": "boolean", |
| "markdownDescription": "Checking for impossible return value from a builtin function\n\nReturn values of the len and cap builtins cannot be negative.\n\nSee https://golang.org/pkg/builtin/#len and https://golang.org/pkg/builtin/#cap.\n\nExample:\n\n if len(slice) < 0 {\n fmt.Println(\"unreachable code\")\n }\n\nAvailable since\n 2021.1\n", |
| "default": true |
| }, |
| "SA4025": { |
| "type": "boolean", |
| "markdownDescription": "Integer division of literals that results in zero\n\nWhen dividing two integer constants, the result will\nalso be an integer. Thus, a division such as 2 / 3 results in 0.\nThis is true for all of the following examples:\n\n\t_ = 2 / 3\n\tconst _ = 2 / 3\n\tconst _ float64 = 2 / 3\n\t_ = float64(2 / 3)\n\nStaticcheck will flag such divisions if both sides of the division are\ninteger literals, as it is highly unlikely that the division was\nintended to truncate to zero. Staticcheck will not flag integer\ndivision involving named constants, to avoid noisy positives.\n\nAvailable since\n 2021.1\n", |
| "default": true |
| }, |
| "SA4026": { |
| "type": "boolean", |
| "markdownDescription": "Go constants cannot express negative zero\n\nIn IEEE 754 floating point math, zero has a sign and can be positive\nor negative. This can be useful in certain numerical code.\n\nGo constants, however, cannot express negative zero. This means that\nthe literals -0.0 and 0.0 have the same ideal value (zero) and\nwill both represent positive zero at runtime.\n\nTo explicitly and reliably create a negative zero, you can use the\nmath.Copysign function: math.Copysign(0, -1).\n\nAvailable since\n 2021.1\n", |
| "default": true |
| }, |
| "SA4027": { |
| "type": "boolean", |
| "markdownDescription": "(*net/url.URL).Query returns a copy, modifying it doesn't change the URL\n\n(*net/url.URL).Query parses the current value of net/url.URL.RawQuery\nand returns it as a map of type net/url.Values. Subsequent changes to\nthis map will not affect the URL unless the map gets encoded and\nassigned to the URL's RawQuery.\n\nAs a consequence, the following code pattern is an expensive no-op:\nu.Query().Add(key, value).\n\nAvailable since\n 2021.1\n", |
| "default": true |
| }, |
| "SA4028": { |
| "type": "boolean", |
| "markdownDescription": "x % 1 is always zero\n\nAvailable since\n 2022.1\n", |
| "default": true |
| }, |
| "SA4029": { |
| "type": "boolean", |
| "markdownDescription": "Ineffective attempt at sorting slice\n\nsort.Float64Slice, sort.IntSlice, and sort.StringSlice are\ntypes, not functions. Doing x = sort.StringSlice(x) does nothing,\nespecially not sort any values. The correct usage is\nsort.Sort(sort.StringSlice(x)) or sort.StringSlice(x).Sort(),\nbut there are more convenient helpers, namely sort.Float64s,\nsort.Ints, and sort.Strings.\n\nAvailable since\n 2022.1\n", |
| "default": true |
| }, |
| "SA4030": { |
| "type": "boolean", |
| "markdownDescription": "Ineffective attempt at generating random number\n\nFunctions in the math/rand package that accept upper limits, such\nas Intn, generate random numbers in the half-open interval [0,n). In\nother words, the generated numbers will be >= 0 and < n – they\ndon't include n. rand.Intn(1) therefore doesn't generate 0\nor 1, it always generates 0.\n\nAvailable since\n 2022.1\n", |
| "default": true |
| }, |
| "SA4031": { |
| "type": "boolean", |
| "markdownDescription": "Checking never-nil value against nil\n\nAvailable since\n 2022.1\n", |
| "default": false |
| }, |
| "SA4032": { |
| "type": "boolean", |
| "markdownDescription": "Comparing runtime.GOOS or runtime.GOARCH against impossible value\n\nAvailable since\n 2024.1\n", |
| "default": true |
| }, |
| "SA5000": { |
| "type": "boolean", |
| "markdownDescription": "Assignment to nil map\n\nAvailable since\n 2017.1\n", |
| "default": false |
| }, |
| "SA5001": { |
| "type": "boolean", |
| "markdownDescription": "Deferring Close before checking for a possible error\n\nAvailable since\n 2017.1\n", |
| "default": true |
| }, |
| "SA5002": { |
| "type": "boolean", |
| "markdownDescription": "The empty for loop ('for {}') spins and can block the scheduler\n\nAvailable since\n 2017.1\n", |
| "default": false |
| }, |
| "SA5003": { |
| "type": "boolean", |
| "markdownDescription": "Defers in infinite loops will never execute\n\nDefers are scoped to the surrounding function, not the surrounding\nblock. In a function that never returns, i.e. one containing an\ninfinite loop, defers will never execute.\n\nAvailable since\n 2017.1\n", |
| "default": true |
| }, |
| "SA5004": { |
| "type": "boolean", |
| "markdownDescription": "'for { select { ...' with an empty default branch spins\n\nAvailable since\n 2017.1\n", |
| "default": true |
| }, |
| "SA5005": { |
| "type": "boolean", |
| "markdownDescription": "The finalizer references the finalized object, preventing garbage collection\n\nA finalizer is a function associated with an object that runs when the\ngarbage collector is ready to collect said object, that is when the\nobject is no longer referenced by anything.\n\nIf the finalizer references the object, however, it will always remain\nas the final reference to that object, preventing the garbage\ncollector from collecting the object. The finalizer will never run,\nand the object will never be collected, leading to a memory leak. That\nis why the finalizer should instead use its first argument to operate\non the object. That way, the number of references can temporarily go\nto zero before the object is being passed to the finalizer.\n\nAvailable since\n 2017.1\n", |
| "default": false |
| }, |
| "SA5007": { |
| "type": "boolean", |
| "markdownDescription": "Infinite recursive call\n\nA function that calls itself recursively needs to have an exit\ncondition. Otherwise it will recurse forever, until the system runs\nout of memory.\n\nThis issue can be caused by simple bugs such as forgetting to add an\nexit condition. It can also happen \"on purpose\". Some languages have\ntail call optimization which makes certain infinite recursive calls\nsafe to use. Go, however, does not implement TCO, and as such a loop\nshould be used instead.\n\nAvailable since\n 2017.1\n", |
| "default": false |
| }, |
| "SA5008": { |
| "type": "boolean", |
| "markdownDescription": "Invalid struct tag\n\nAvailable since\n 2019.2\n", |
| "default": true |
| }, |
| "SA5010": { |
| "type": "boolean", |
| "markdownDescription": "Impossible type assertion\n\nSome type assertions can be statically proven to be\nimpossible. This is the case when the method sets of both\narguments of the type assertion conflict with each other, for\nexample by containing the same method with different\nsignatures.\n\nThe Go compiler already applies this check when asserting from an\ninterface value to a concrete type. If the concrete type misses\nmethods from the interface, or if function signatures don't match,\nthen the type assertion can never succeed.\n\nThis check applies the same logic when asserting from one interface to\nanother. If both interface types contain the same method but with\ndifferent signatures, then the type assertion can never succeed,\neither.\n\nAvailable since\n 2020.1\n", |
| "default": false |
| }, |
| "SA5011": { |
| "type": "boolean", |
| "markdownDescription": "Possible nil pointer dereference\n\nA pointer is being dereferenced unconditionally, while\nalso being checked against nil in another place. This suggests that\nthe pointer may be nil and dereferencing it may panic. This is\ncommonly a result of improperly ordered code or missing return\nstatements. Consider the following examples:\n\n func fn(x *int) {\n fmt.Println(*x)\n\n // This nil check is equally important for the previous dereference\n if x != nil {\n foo(*x)\n }\n }\n\n func TestFoo(t *testing.T) {\n x := compute()\n if x == nil {\n t.Errorf(\"nil pointer received\")\n }\n\n // t.Errorf does not abort the test, so if x is nil, the next line will panic.\n foo(*x)\n }\n\nStaticcheck tries to deduce which functions abort control flow.\nFor example, it is aware that a function will not continue\nexecution after a call to panic or log.Fatal. However, sometimes\nthis detection fails, in particular in the presence of\nconditionals. Consider the following example:\n\n func Log(msg string, level int) {\n fmt.Println(msg)\n if level == levelFatal {\n os.Exit(1)\n }\n }\n\n func Fatal(msg string) {\n Log(msg, levelFatal)\n }\n\n func fn(x *int) {\n if x == nil {\n Fatal(\"unexpected nil pointer\")\n }\n fmt.Println(*x)\n }\n\nStaticcheck will flag the dereference of x, even though it is perfectly\nsafe. Staticcheck is not able to deduce that a call to\nFatal will exit the program. For the time being, the easiest\nworkaround is to modify the definition of Fatal like so:\n\n func Fatal(msg string) {\n Log(msg, levelFatal)\n panic(\"unreachable\")\n }\n\nWe also hard-code functions from common logging packages such as\nlogrus. Please file an issue if we're missing support for a\npopular package.\n\nAvailable since\n 2020.1\n", |
| "default": false |
| }, |
| "SA5012": { |
| "type": "boolean", |
| "markdownDescription": "Passing odd-sized slice to function expecting even size\n\nSome functions that take slices as parameters expect the slices to have an even number of elements. \nOften, these functions treat elements in a slice as pairs. \nFor example, strings.NewReplacer takes pairs of old and new strings, \nand calling it with an odd number of elements would be an error.\n\nAvailable since\n 2020.2\n", |
| "default": false |
| }, |
| "SA6000": { |
| "type": "boolean", |
| "markdownDescription": "Using regexp.Match or related in a loop, should use regexp.Compile\n\nAvailable since\n 2017.1\n", |
| "default": false |
| }, |
| "SA6001": { |
| "type": "boolean", |
| "markdownDescription": "Missing an optimization opportunity when indexing maps by byte slices\n\nMap keys must be comparable, which precludes the use of byte slices.\nThis usually leads to using string keys and converting byte slices to\nstrings.\n\nNormally, a conversion of a byte slice to a string needs to copy the data and\ncauses allocations. The compiler, however, recognizes m[string(b)] and\nuses the data of b directly, without copying it, because it knows that\nthe data can't change during the map lookup. This leads to the\ncounter-intuitive situation that\n\n k := string(b)\n println(m[k])\n println(m[k])\n\nwill be less efficient than\n\n println(m[string(b)])\n println(m[string(b)])\n\nbecause the first version needs to copy and allocate, while the second\none does not.\n\nFor some history on this optimization, check out commit\nf5f5a8b6209f84961687d993b93ea0d397f5d5bf in the Go repository.\n\nAvailable since\n 2017.1\n", |
| "default": false |
| }, |
| "SA6002": { |
| "type": "boolean", |
| "markdownDescription": "Storing non-pointer values in sync.Pool allocates memory\n\nA sync.Pool is used to avoid unnecessary allocations and reduce the\namount of work the garbage collector has to do.\n\nWhen passing a value that is not a pointer to a function that accepts\nan interface, the value needs to be placed on the heap, which means an\nadditional allocation. Slices are a common thing to put in sync.Pools,\nand they're structs with 3 fields (length, capacity, and a pointer to\nan array). In order to avoid the extra allocation, one should store a\npointer to the slice instead.\n\nSee the comments on https://go-review.googlesource.com/c/go/+/24371\nthat discuss this problem.\n\nAvailable since\n 2017.1\n", |
| "default": false |
| }, |
| "SA6003": { |
| "type": "boolean", |
| "markdownDescription": "Converting a string to a slice of runes before ranging over it\n\nYou may want to loop over the runes in a string. Instead of converting\nthe string to a slice of runes and looping over that, you can loop\nover the string itself. That is,\n\n for _, r := range s {}\n\nand\n\n for _, r := range []rune(s) {}\n\nwill yield the same values. The first version, however, will be faster\nand avoid unnecessary memory allocations.\n\nDo note that if you are interested in the indices, ranging over a\nstring and over a slice of runes will yield different indices. The\nfirst one yields byte offsets, while the second one yields indices in\nthe slice of runes.\n\nAvailable since\n 2017.1\n", |
| "default": false |
| }, |
| "SA6005": { |
| "type": "boolean", |
| "markdownDescription": "Inefficient string comparison with strings.ToLower or strings.ToUpper\n\nConverting two strings to the same case and comparing them like so\n\n if strings.ToLower(s1) == strings.ToLower(s2) {\n ...\n }\n\nis significantly more expensive than comparing them with\nstrings.EqualFold(s1, s2). This is due to memory usage as well as\ncomputational complexity.\n\nstrings.ToLower will have to allocate memory for the new strings, as\nwell as convert both strings fully, even if they differ on the very\nfirst byte. strings.EqualFold, on the other hand, compares the strings\none character at a time. It doesn't need to create two intermediate\nstrings and can return as soon as the first non-matching character has\nbeen found.\n\nFor a more in-depth explanation of this issue, see\nhttps://blog.digitalocean.com/how-to-efficiently-compare-strings-in-go/\n\nAvailable since\n 2019.2\n", |
| "default": true |
| }, |
| "SA6006": { |
| "type": "boolean", |
| "markdownDescription": "Using io.WriteString to write []byte\n\nUsing io.WriteString to write a slice of bytes, as in\n\n io.WriteString(w, string(b))\n\nis both unnecessary and inefficient. Converting from []byte to string\nhas to allocate and copy the data, and we could simply use w.Write(b)\ninstead.\n\nAvailable since\n 2024.1\n", |
| "default": true |
| }, |
| "SA9001": { |
| "type": "boolean", |
| "markdownDescription": "Defers in range loops may not run when you expect them to\n\nAvailable since\n 2017.1\n", |
| "default": false |
| }, |
| "SA9002": { |
| "type": "boolean", |
| "markdownDescription": "Using a non-octal os.FileMode that looks like it was meant to be in octal.\n\nAvailable since\n 2017.1\n", |
| "default": true |
| }, |
| "SA9003": { |
| "type": "boolean", |
| "markdownDescription": "Empty body in an if or else branch\n\nAvailable since\n 2017.1, non-default\n", |
| "default": false |
| }, |
| "SA9004": { |
| "type": "boolean", |
| "markdownDescription": "Only the first constant has an explicit type\n\nIn a constant declaration such as the following:\n\n const (\n First byte = 1\n Second = 2\n )\n\nthe constant Second does not have the same type as the constant First.\nThis construct shouldn't be confused with\n\n const (\n First byte = iota\n Second\n )\n\nwhere First and Second do indeed have the same type. The type is only\npassed on when no explicit value is assigned to the constant.\n\nWhen declaring enumerations with explicit values it is therefore\nimportant not to write\n\n const (\n EnumFirst EnumType = 1\n EnumSecond = 2\n EnumThird = 3\n )\n\nThis discrepancy in types can cause various confusing behaviors and\nbugs.\n\n\nWrong type in variable declarations\n\nThe most obvious issue with such incorrect enumerations expresses\nitself as a compile error:\n\n package pkg\n\n const (\n EnumFirst uint8 = 1\n EnumSecond = 2\n )\n\n func fn(useFirst bool) {\n x := EnumSecond\n if useFirst {\n x = EnumFirst\n }\n }\n\nfails to compile with\n\n ./const.go:11:5: cannot use EnumFirst (type uint8) as type int in assignment\n\n\nLosing method sets\n\nA more subtle issue occurs with types that have methods and optional\ninterfaces. Consider the following:\n\n package main\n\n import \"fmt\"\n\n type Enum int\n\n func (e Enum) String() string {\n return \"an enum\"\n }\n\n const (\n EnumFirst Enum = 1\n EnumSecond = 2\n )\n\n func main() {\n fmt.Println(EnumFirst)\n fmt.Println(EnumSecond)\n }\n\nThis code will output\n\n an enum\n 2\n\nas EnumSecond has no explicit type, and thus defaults to int.\n\nAvailable since\n 2019.1\n", |
| "default": true |
| }, |
| "SA9005": { |
| "type": "boolean", |
| "markdownDescription": "Trying to marshal a struct with no public fields nor custom marshaling\n\nThe encoding/json and encoding/xml packages only operate on exported\nfields in structs, not unexported ones. It is usually an error to try\nto (un)marshal structs that only consist of unexported fields.\n\nThis check will not flag calls involving types that define custom\nmarshaling behavior, e.g. via MarshalJSON methods. It will also not\nflag empty structs.\n\nAvailable since\n 2019.2\n", |
| "default": false |
| }, |
| "SA9006": { |
| "type": "boolean", |
| "markdownDescription": "Dubious bit shifting of a fixed size integer value\n\nBit shifting a value past its size will always clear the value.\n\nFor instance:\n\n v := int8(42)\n v >>= 8\n\nwill always result in 0.\n\nThis check flags bit shifting operations on fixed size integer values only.\nThat is, int, uint and uintptr are never flagged to avoid potential false\npositives in somewhat exotic but valid bit twiddling tricks:\n\n // Clear any value above 32 bits if integers are more than 32 bits.\n func f(i int) int {\n v := i >> 32\n v = v << 32\n return i-v\n }\n\nAvailable since\n 2020.2\n", |
| "default": true |
| }, |
| "SA9007": { |
| "type": "boolean", |
| "markdownDescription": "Deleting a directory that shouldn't be deleted\n\nIt is virtually never correct to delete system directories such as\n/tmp or the user's home directory. However, it can be fairly easy to\ndo by mistake, for example by mistakenly using os.TempDir instead\nof ioutil.TempDir, or by forgetting to add a suffix to the result\nof os.UserHomeDir.\n\nWriting\n\n d := os.TempDir()\n defer os.RemoveAll(d)\n\nin your unit tests will have a devastating effect on the stability of your system.\n\nThis check flags attempts at deleting the following directories:\n\n- os.TempDir\n- os.UserCacheDir\n- os.UserConfigDir\n- os.UserHomeDir\n\nAvailable since\n 2022.1\n", |
| "default": false |
| }, |
| "SA9008": { |
| "type": "boolean", |
| "markdownDescription": "else branch of a type assertion is probably not reading the right value\n\nWhen declaring variables as part of an if statement (like in 'if\nfoo := ...; foo {'), the same variables will also be in the scope of\nthe else branch. This means that in the following example\n\n if x, ok := x.(int); ok {\n // ...\n } else {\n fmt.Printf(\"unexpected type %T\", x)\n }\n\nx in the else branch will refer to the x from x, ok\n:=; it will not refer to the x that is being type-asserted. The\nresult of a failed type assertion is the zero value of the type that\nis being asserted to, so x in the else branch will always have the\nvalue 0 and the type int.\n\nAvailable since\n 2022.1\n", |
| "default": false |
| }, |
| "SA9009": { |
| "type": "boolean", |
| "markdownDescription": "Ineffectual Go compiler directive\n\nA potential Go compiler directive was found, but is ineffectual as it begins\nwith whitespace.\n\nAvailable since\n 2024.1\n", |
| "default": true |
| }, |
| "ST1000": { |
| "type": "boolean", |
| "markdownDescription": "Incorrect or missing package comment\n\nPackages must have a package comment that is formatted according to\nthe guidelines laid out in\nhttps://go.dev/wiki/CodeReviewComments#package-comments.\n\nAvailable since\n 2019.1, non-default\n", |
| "default": false |
| }, |
| "ST1001": { |
| "type": "boolean", |
| "markdownDescription": "Dot imports are discouraged\n\nDot imports that aren't in external test packages are discouraged.\n\nThe dot_import_whitelist option can be used to whitelist certain\nimports.\n\nQuoting Go Code Review Comments:\n\n> The import . form can be useful in tests that, due to circular\n> dependencies, cannot be made part of the package being tested:\n> \n> package foo_test\n> \n> import (\n> \"bar/testutil\" // also imports \"foo\"\n> . \"foo\"\n> )\n> \n> In this case, the test file cannot be in package foo because it\n> uses bar/testutil, which imports foo. So we use the import .\n> form to let the file pretend to be part of package foo even though\n> it is not. Except for this one case, do not use import . in your\n> programs. It makes the programs much harder to read because it is\n> unclear whether a name like Quux is a top-level identifier in the\n> current package or in an imported package.\n\nAvailable since\n 2019.1\n\nOptions\n dot_import_whitelist\n", |
| "default": false |
| }, |
| "ST1003": { |
| "type": "boolean", |
| "markdownDescription": "Poorly chosen identifier\n\nIdentifiers, such as variable and package names, follow certain rules.\n\nSee the following links for details:\n\n- https://go.dev/doc/effective_go#package-names\n- https://go.dev/doc/effective_go#mixed-caps\n- https://go.dev/wiki/CodeReviewComments#initialisms\n- https://go.dev/wiki/CodeReviewComments#variable-names\n\nAvailable since\n 2019.1, non-default\n\nOptions\n initialisms\n", |
| "default": false |
| }, |
| "ST1005": { |
| "type": "boolean", |
| "markdownDescription": "Incorrectly formatted error string\n\nError strings follow a set of guidelines to ensure uniformity and good\ncomposability.\n\nQuoting Go Code Review Comments:\n\n> Error strings should not be capitalized (unless beginning with\n> proper nouns or acronyms) or end with punctuation, since they are\n> usually printed following other context. That is, use\n> fmt.Errorf(\"something bad\") not fmt.Errorf(\"Something bad\"), so\n> that log.Printf(\"Reading %s: %v\", filename, err) formats without a\n> spurious capital letter mid-message.\n\nAvailable since\n 2019.1\n", |
| "default": false |
| }, |
| "ST1006": { |
| "type": "boolean", |
| "markdownDescription": "Poorly chosen receiver name\n\nQuoting Go Code Review Comments:\n\n> The name of a method's receiver should be a reflection of its\n> identity; often a one or two letter abbreviation of its type\n> suffices (such as \"c\" or \"cl\" for \"Client\"). Don't use generic\n> names such as \"me\", \"this\" or \"self\", identifiers typical of\n> object-oriented languages that place more emphasis on methods as\n> opposed to functions. The name need not be as descriptive as that\n> of a method argument, as its role is obvious and serves no\n> documentary purpose. It can be very short as it will appear on\n> almost every line of every method of the type; familiarity admits\n> brevity. Be consistent, too: if you call the receiver \"c\" in one\n> method, don't call it \"cl\" in another.\n\nAvailable since\n 2019.1\n", |
| "default": false |
| }, |
| "ST1008": { |
| "type": "boolean", |
| "markdownDescription": "A function's error value should be its last return value\n\nA function's error value should be its last return value.\n\nAvailable since\n 2019.1\n", |
| "default": false |
| }, |
| "ST1011": { |
| "type": "boolean", |
| "markdownDescription": "Poorly chosen name for variable of type time.Duration\n\ntime.Duration values represent an amount of time, which is represented\nas a count of nanoseconds. An expression like 5 * time.Microsecond\nyields the value 5000. It is therefore not appropriate to suffix a\nvariable of type time.Duration with any time unit, such as Msec or\nMilli.\n\nAvailable since\n 2019.1\n", |
| "default": false |
| }, |
| "ST1012": { |
| "type": "boolean", |
| "markdownDescription": "Poorly chosen name for error variable\n\nError variables that are part of an API should be called errFoo or\nErrFoo.\n\nAvailable since\n 2019.1\n", |
| "default": false |
| }, |
| "ST1013": { |
| "type": "boolean", |
| "markdownDescription": "Should use constants for HTTP error codes, not magic numbers\n\nHTTP has a tremendous number of status codes. While some of those are\nwell known (200, 400, 404, 500), most of them are not. The net/http\npackage provides constants for all status codes that are part of the\nvarious specifications. It is recommended to use these constants\ninstead of hard-coding magic numbers, to vastly improve the\nreadability of your code.\n\nAvailable since\n 2019.1\n\nOptions\n http_status_code_whitelist\n", |
| "default": false |
| }, |
| "ST1015": { |
| "type": "boolean", |
| "markdownDescription": "A switch's default case should be the first or last case\n\nAvailable since\n 2019.1\n", |
| "default": false |
| }, |
| "ST1016": { |
| "type": "boolean", |
| "markdownDescription": "Use consistent method receiver names\n\nAvailable since\n 2019.1, non-default\n", |
| "default": false |
| }, |
| "ST1017": { |
| "type": "boolean", |
| "markdownDescription": "Don't use Yoda conditions\n\nYoda conditions are conditions of the kind 'if 42 == x', where the\nliteral is on the left side of the comparison. These are a common\nidiom in languages in which assignment is an expression, to avoid bugs\nof the kind 'if (x = 42)'. In Go, which doesn't allow for this kind of\nbug, we prefer the more idiomatic 'if x == 42'.\n\nAvailable since\n 2019.2\n", |
| "default": false |
| }, |
| "ST1018": { |
| "type": "boolean", |
| "markdownDescription": "Avoid zero-width and control characters in string literals\n\nAvailable since\n 2019.2\n", |
| "default": false |
| }, |
| "ST1019": { |
| "type": "boolean", |
| "markdownDescription": "Importing the same package multiple times\n\nGo allows importing the same package multiple times, as long as\ndifferent import aliases are being used. That is, the following\nbit of code is valid:\n\n import (\n \"fmt\"\n fumpt \"fmt\"\n format \"fmt\"\n _ \"fmt\"\n )\n\nHowever, this is very rarely done on purpose. Usually, it is a\nsign of code that got refactored, accidentally adding duplicate\nimport statements. It is also a rarely known feature, which may\ncontribute to confusion.\n\nDo note that sometimes, this feature may be used\nintentionally (see for example\nhttps://github.com/golang/go/commit/3409ce39bfd7584523b7a8c150a310cea92d879d)\n– if you want to allow this pattern in your code base, you're\nadvised to disable this check.\n\nAvailable since\n 2020.1\n", |
| "default": false |
| }, |
| "ST1020": { |
| "type": "boolean", |
| "markdownDescription": "The documentation of an exported function should start with the function's name\n\nDoc comments work best as complete sentences, which\nallow a wide variety of automated presentations. The first sentence\nshould be a one-sentence summary that starts with the name being\ndeclared.\n\nIf every doc comment begins with the name of the item it describes,\nyou can use the doc subcommand of the go tool and run the output\nthrough grep.\n\nSee https://go.dev/doc/effective_go#commentary for more\ninformation on how to write good documentation.\n\nAvailable since\n 2020.1, non-default\n", |
| "default": false |
| }, |
| "ST1021": { |
| "type": "boolean", |
| "markdownDescription": "The documentation of an exported type should start with type's name\n\nDoc comments work best as complete sentences, which\nallow a wide variety of automated presentations. The first sentence\nshould be a one-sentence summary that starts with the name being\ndeclared.\n\nIf every doc comment begins with the name of the item it describes,\nyou can use the doc subcommand of the go tool and run the output\nthrough grep.\n\nSee https://go.dev/doc/effective_go#commentary for more\ninformation on how to write good documentation.\n\nAvailable since\n 2020.1, non-default\n", |
| "default": false |
| }, |
| "ST1022": { |
| "type": "boolean", |
| "markdownDescription": "The documentation of an exported variable or constant should start with variable's name\n\nDoc comments work best as complete sentences, which\nallow a wide variety of automated presentations. The first sentence\nshould be a one-sentence summary that starts with the name being\ndeclared.\n\nIf every doc comment begins with the name of the item it describes,\nyou can use the doc subcommand of the go tool and run the output\nthrough grep.\n\nSee https://go.dev/doc/effective_go#commentary for more\ninformation on how to write good documentation.\n\nAvailable since\n 2020.1, non-default\n", |
| "default": false |
| }, |
| "ST1023": { |
| "type": "boolean", |
| "markdownDescription": "Redundant type in variable declaration\n\nAvailable since\n 2021.1, non-default\n", |
| "default": false |
| }, |
| "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 |
| }, |
| "gofix": { |
| "type": "boolean", |
| "markdownDescription": "apply fixes based on go:fix comment directives\n\nThe gofix analyzer inlines functions and constants that are marked for inlining.\n\n## Functions\n\nGiven a function that is marked for inlining, like this one:\n\n\t//go:fix inline\n\tfunc Square(x int) int { return Pow(x, 2) }\n\nthis analyzer will recommend that calls to the function elsewhere, in the same\nor other packages, should be inlined.\n\nInlining can be used to move off of a deprecated function:\n\n\t// Deprecated: prefer Pow(x, 2).\n\t//go:fix inline\n\tfunc Square(x int) int { return Pow(x, 2) }\n\nIt can also be used to move off of an obsolete package,\nas when the import path has changed or a higher major version is available:\n\n\tpackage pkg\n\n\timport pkg2 \"pkg/v2\"\n\n\t//go:fix inline\n\tfunc F() { pkg2.F(nil) }\n\nReplacing a call pkg.F() by pkg2.F(nil) can have no effect on the program,\nso this mechanism provides a low-risk way to update large numbers of calls.\nWe recommend, where possible, expressing the old API in terms of the new one\nto enable automatic migration.\n\nThe inliner takes care to avoid behavior changes, even subtle ones,\nsuch as changes to the order in which argument expressions are\nevaluated. When it cannot safely eliminate all parameter variables,\nit may introduce a \"binding declaration\" of the form\n\n\tvar params = args\n\nto evaluate argument expressions in the correct order and bind them to\nparameter variables. Since the resulting code transformation may be\nstylistically suboptimal, such inlinings may be disabled by specifying\nthe -gofix.allow_binding_decl=false flag to the analyzer driver.\n\n(In cases where it is not safe to \"reduce\" a call—that is, to replace\na call f(x) by the body of function f, suitably substituted—the\ninliner machinery is capable of replacing f by a function literal,\nfunc(){...}(). However, the gofix analyzer discards all such\n\"literalizations\" unconditionally, again on grounds of style.)\n\n## Constants\n\nGiven a constant that is marked for inlining, like this one:\n\n\t//go:fix inline\n\tconst Ptr = Pointer\n\nthis analyzer will recommend that uses of Ptr should be replaced with Pointer.\n\nAs with functions, inlining can be used to replace deprecated constants and\nconstants in obsolete packages.\n\nA constant definition can be marked for inlining only if it refers to another\nnamed constant.\n\nThe \"//go:fix inline\" comment must appear before a single const declaration on its own,\nas above; before a const declaration that is part of a group, as in this case:\n\n\tconst (\n\t C = 1\n\t //go:fix inline\n\t Ptr = Pointer\n\t)\n\nor before a group, applying to every constant in the group:\n\n\t//go:fix inline\n\tconst (\n\t\tPtr = Pointer\n\t Val = Value\n\t)\n\nThe proposal https://go.dev/issue/32816 introduces the \"//go:fix\" directives.\n\nYou can use this (officially unsupported) command to apply gofix fixes en masse:\n\n\t$ go run golang.org/x/tools/internal/gofix/cmd/gofix@latest -test ./...\n\n(Do not use \"go get -tool\" to add gopls as a dependency of your\nmodule; gopls commands must be built from their release branch.)", |
| "default": true |
| }, |
| "hostport": { |
| "type": "boolean", |
| "markdownDescription": "check format of addresses passed to net.Dial\n\nThis analyzer flags code that produce network address strings using\nfmt.Sprintf, as in this example:\n\n addr := fmt.Sprintf(\"%s:%d\", host, 12345) // \"will not work with IPv6\"\n ...\n conn, err := net.Dial(\"tcp\", addr) // \"when passed to dial here\"\n\nThe analyzer suggests a fix to use the correct approach, a call to\nnet.JoinHostPort:\n\n addr := net.JoinHostPort(host, \"12345\")\n ...\n conn, err := net.Dial(\"tcp\", addr)\n\nA similar diagnostic and fix are produced for a format string of \"%s:%s\".\n", |
| "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 [<go1.22].\n\n\tfor _, v := range list {\n\t defer func() {\n\t use(v) // incorrect\n\t }()\n\t}\n\nOne fix is to create a new variable for each iteration of the loop:\n\n\tfor _, v := range list {\n\t v := v // new var per iteration\n\t defer func() {\n\t use(v) // ok\n\t }()\n\t}\n\nAfter Go version 1.22, the previous two for loops are equivalent\nand both are correct.\n\nThe next example uses a go statement and has a similar problem [<go1.22].\nIn addition, it has a data race because the loop updates v\nconcurrent with the goroutines accessing it.\n\n\tfor _, v := range elem {\n\t go func() {\n\t use(v) // incorrect, and a data race\n\t }()\n\t}\n\nA fix is the same as before. The checker also reports problems\nin goroutines started by golang.org/x/sync/errgroup.Group.\nA hard-to-spot variant of this form is common in parallel tests:\n\n\tfunc Test(t *testing.T) {\n\t for _, test := range tests {\n\t t.Run(test.name, func(t *testing.T) {\n\t t.Parallel()\n\t use(test) // incorrect, and a data race\n\t })\n\t }\n\t}\n\nThe t.Parallel() call causes the rest of the function to execute\nconcurrent with the loop [<go1.22].\n\nThe analyzer reports references only in the last statement,\nas it is not deep enough to understand the effects of subsequent\nstatements that might render the reference benign.\n(\"Last statement\" is defined recursively in compound\nstatements such as if, switch, and select.)\n\nSee: https://golang.org/doc/go_faq.html#closures_and_goroutines", |
| "default": true |
| }, |
| "lostcancel": { |
| "type": "boolean", |
| "markdownDescription": "check cancel func returned by context.WithCancel is called\n\nThe cancellation function returned by context.WithCancel, WithTimeout,\nWithDeadline and variants such as WithCancelCause must be called,\nor the new context will remain live until its parent context is cancelled.\n(The background context is never cancelled.)", |
| "default": true |
| }, |
| "maprange": { |
| "type": "boolean", |
| "markdownDescription": "checks for unnecessary calls to maps.Keys and maps.Values in range statements\n\nConsider a loop written like this:\n\n\tfor val := range maps.Values(m) {\n\t\tfmt.Println(val)\n\t}\n\nThis should instead be written without the call to maps.Values:\n\n\tfor _, val := range m {\n\t\tfmt.Println(val)\n\t}\n\ngolang.org/x/exp/maps returns slices for Keys/Values instead of iterators,\nbut unnecessary calls should similarly be removed:\n\n\tfor _, key := range maps.Keys(m) {\n\t\tfmt.Println(key)\n\t}\n\nshould be rewritten as:\n\n\tfor key := range m {\n\t\tfmt.Println(key)\n\t}", |
| "default": true |
| }, |
| "modernize": { |
| "type": "boolean", |
| "markdownDescription": "simplify code by using modern constructs\n\nThis analyzer reports opportunities for simplifying and clarifying\nexisting code by using more modern features of Go and its standard\nlibrary.\n\nEach diagnostic provides a fix. Our intent is that these fixes may\nbe safely applied en masse without changing the behavior of your\nprogram. In some cases the suggested fixes are imperfect and may\nlead to (for example) unused imports or unused local variables,\ncausing build breakage. However, these problems are generally\ntrivial to fix. We regard any modernizer whose fix changes program\nbehavior to have a serious bug and will endeavor to fix it.\n\nTo apply all modernization fixes en masse, you can use the\nfollowing command:\n\n\t$ go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -fix -test ./...\n\n(Do not use \"go get -tool\" to add gopls as a dependency of your\nmodule; gopls commands must be built from their release branch.)\n\nIf the tool warns of conflicting fixes, you may need to run it more\nthan once until it has applied all fixes cleanly. This command is\nnot an officially supported interface and may change in the future.\n\nChanges produced by this tool should be reviewed as usual before\nbeing merged. In some cases, a loop may be replaced by a simple\nfunction call, causing comments within the loop to be discarded.\nHuman judgment may be required to avoid losing comments of value.\n\nEach diagnostic reported by modernize has a specific category. (The\ncategories are listed below.) Diagnostics in some categories, such\nas \"efaceany\" (which replaces \"interface{}\" with \"any\" where it is\nsafe to do so) are particularly numerous. It may ease the burden of\ncode review to apply fixes in two passes, the first change\nconsisting only of fixes of category \"efaceany\", the second\nconsisting of all others. This can be achieved using the -category flag:\n\n\t$ modernize -category=efaceany -fix -test ./...\n\t$ modernize -category=-efaceany -fix -test ./...\n\nCategories of modernize diagnostic:\n\n - forvar: remove x := x variable declarations made unnecessary by the new semantics of loops in go1.22.\n\n - slicescontains: replace 'for i, elem := range s { if elem == needle { ...; break }'\n by a call to slices.Contains, added in go1.21.\n\n - minmax: replace an if/else conditional assignment by a call to\n the built-in min or max functions added in go1.21.\n\n - sortslice: replace sort.Slice(x, func(i, j int) bool) { return s[i] < s[j] }\n by a call to slices.Sort(s), added in go1.21.\n\n - efaceany: replace interface{} by the 'any' type added in go1.18.\n\n - mapsloop: replace a loop around an m[k]=v map update by a call\n to one of the Collect, Copy, Clone, or Insert functions from\n the maps package, added in go1.21.\n\n - fmtappendf: replace []byte(fmt.Sprintf...) by fmt.Appendf(nil, ...),\n added in go1.19.\n\n - testingcontext: replace uses of context.WithCancel in tests\n with t.Context, added in go1.24.\n\n - omitzero: replace omitempty by omitzero on structs, added in go1.24.\n\n - bloop: replace \"for i := range b.N\" or \"for range b.N\" in a\n benchmark with \"for b.Loop()\", and remove any preceding calls\n to b.StopTimer, b.StartTimer, and b.ResetTimer.\n\n B.Loop intentionally defeats compiler optimizations such as\n inlining so that the benchmark is not entirely optimized away.\n Currently, however, it may cause benchmarks to become slower\n in some cases due to increased allocation; see\n https://go.dev/issue/73137.\n\n - rangeint: replace a 3-clause \"for i := 0; i < n; i++\" loop by\n \"for i := range n\", added in go1.22.\n\n - stringsseq: replace Split in \"for range strings.Split(...)\" by go1.24's\n more efficient SplitSeq, or Fields with FieldSeq.\n\n - stringscutprefix: replace some uses of HasPrefix followed by TrimPrefix with CutPrefix,\n added to the strings package in go1.20.\n\n - waitgroup: replace old complex usages of sync.WaitGroup by less complex WaitGroup.Go method in go1.25.", |
| "default": true |
| }, |
| "nilfunc": { |
| "type": "boolean", |
| "markdownDescription": "check for useless comparisons between functions and nil\n\nA useless comparison is one like f == nil as opposed to f() == nil.", |
| "default": true |
| }, |
| "nilness": { |
| "type": "boolean", |
| "markdownDescription": "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\nSometimes the control flow may be quite complex, making bugs hard\nto spot. In the example below, the err.Error expression is\nguaranteed to panic because, after the first return, err must be\nnil. The intervening loop is just a distraction.\n\n\t...\n\terr := g.Wait()\n\tif err != nil {\n\t\treturn err\n\t}\n\tpartialSuccess := false\n\tfor _, err := range errs {\n\t\tif err == nil {\n\t\t\tpartialSuccess = true\n\t\t\tbreak\n\t\t}\n\t}\n\tif partialSuccess {\n\t\treportStatus(StatusMessage{\n\t\t\tCode: code.ERROR,\n\t\t\tDetail: err.Error(), // \"nil dereference in dynamic method call\"\n\t\t})\n\t\treturn nil\n\t}\n\n...", |
| "default": true |
| }, |
| "nonewvars": { |
| "type": "boolean", |
| "markdownDescription": "suggested fixes for \"no new vars on left side of :=\"\n\nThis checker provides suggested fixes for type errors of the\ntype \"no new vars on left side of :=\". For example:\n\n\tz := 1\n\tz := 2\n\nwill turn into\n\n\tz := 1\n\tz = 2", |
| "default": true |
| }, |
| "noresultvalues": { |
| "type": "boolean", |
| "markdownDescription": "suggested fixes for unexpected return values\n\nThis checker provides suggested fixes for type errors of the\ntype \"no result values expected\" or \"too many return values\".\nFor example:\n\n\tfunc z() { return nil }\n\nwill turn into\n\n\tfunc z() { return }", |
| "default": true |
| }, |
| "printf": { |
| "type": "boolean", |
| "markdownDescription": "check consistency of Printf format strings and arguments\n\nThe check applies to calls of the formatting functions such as\n[fmt.Printf] and [fmt.Sprintf], as well as any detected wrappers of\nthose functions such as [log.Printf]. It reports a variety of\nmistakes such as syntax errors in the format string and mismatches\n(of number and type) between the verbs and their arguments.\n\nSee the documentation of the fmt package for the complete set of\nformat operators and their operand types.", |
| "default": true |
| }, |
| "recursiveiter": { |
| "type": "boolean", |
| "markdownDescription": "check for inefficient recursive iterators\n\nThis analyzer reports when a function that returns an iterator\n(iter.Seq or iter.Seq2) calls itself as the operand of a range\nstatement, as this is inefficient.\n\nWhen implementing an iterator (e.g. iter.Seq[T]) for a recursive\ndata type such as a tree or linked list, it is tempting to\nrecursively range over the iterator for each child element.\n\nHere's an example of a naive iterator over a binary tree:\n\n\ttype tree struct {\n\t\tvalue int\n\t\tleft, right *tree\n\t}\n\n\tfunc (t *tree) All() iter.Seq[int] {\n\t\treturn func(yield func(int) bool) {\n\t\t\tif t != nil {\n\t\t\t\tfor elem := range t.left.All() { // \"inefficient recursive iterator\"\n\t\t\t\t\tif !yield(elem) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif !yield(t.value) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tfor elem := range t.right.All() { // \"inefficient recursive iterator\"\n\t\t\t\t\tif !yield(elem) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\nThough it correctly enumerates the elements of the tree, it hides a\nsignificant performance problem--two, in fact. Consider a balanced\ntree of N nodes. Iterating the root node will cause All to be\ncalled once on every node of the tree. This results in a chain of\nnested active range-over-func statements when yield(t.value) is\ncalled on a leaf node.\n\nThe first performance problem is that each range-over-func\nstatement must typically heap-allocate a variable, so iteration of\nthe tree allocates as many variables as there are elements in the\ntree, for a total of O(N) allocations, all unnecessary.\n\nThe second problem is that each call to yield for a leaf of the\ntree causes each of the enclosing range loops to receive a value,\nwhich they then immediately pass on to their respective yield\nfunction. This results in a chain of log(N) dynamic yield calls per\nelement, a total of O(N*log N) dynamic calls overall, when only\nO(N) are necessary.\n\nA better implementation strategy for recursive iterators is to\nfirst define the \"every\" operator for your recursive data type,\nwhere every(f) reports whether f(x) is true for every element x in\nthe data type. For our tree, the every function would be:\n\n\tfunc (t *tree) every(f func(int) bool) bool {\n\t\treturn t == nil ||\n\t\t\tt.left.every(f) && f(t.value) && t.right.every(f)\n\t}\n\nThen the iterator can be simply expressed as a trivial wrapper\naround this function:\n\n\tfunc (t *tree) All() iter.Seq[int] {\n\t\treturn func(yield func(int) bool) {\n\t\t\t_ = t.every(yield)\n\t\t}\n\t}\n\nIn effect, tree.All computes whether yield returns true for each\nelement, short-circuiting if it every returns false, then discards\nthe final boolean result.\n\nThis has much better performance characteristics: it makes one\ndynamic call per element of the tree, and it doesn't heap-allocate\nanything. It is also clearer.", |
| "default": true |
| }, |
| "shadow": { |
| "type": "boolean", |
| "markdownDescription": "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}", |
| "default": false |
| }, |
| "shift": { |
| "type": "boolean", |
| "markdownDescription": "check for shifts that equal or exceed the width of the integer", |
| "default": true |
| }, |
| "sigchanyzer": { |
| "type": "boolean", |
| "markdownDescription": "check for unbuffered channel of os.Signal\n\nThis checker reports call expression of the form\n\n\tsignal.Notify(c <-chan os.Signal, sig ...os.Signal),\n\nwhere c is an unbuffered channel, which can be at risk of missing the signal.", |
| "default": true |
| }, |
| "simplifycompositelit": { |
| "type": "boolean", |
| "markdownDescription": "check for composite literal simplifications\n\nAn array, slice, or map composite literal of the form:\n\n\t[]T{T{}, T{}}\n\nwill be simplified to:\n\n\t[]T{{}, {}}\n\nThis is one of the simplifications that \"gofmt -s\" applies.\n\nThis analyzer ignores generated code.", |
| "default": true |
| }, |
| "simplifyrange": { |
| "type": "boolean", |
| "markdownDescription": "check for range statement simplifications\n\nA range of the form:\n\n\tfor x, _ = range v {...}\n\nwill be simplified to:\n\n\tfor x = range v {...}\n\nA range of the form:\n\n\tfor _ = range v {...}\n\nwill be simplified to:\n\n\tfor range v {...}\n\nThis is one of the simplifications that \"gofmt -s\" applies.\n\nThis analyzer ignores generated code.", |
| "default": true |
| }, |
| "simplifyslice": { |
| "type": "boolean", |
| "markdownDescription": "check for slice simplifications\n\nA slice expression of the form:\n\n\ts[a:len(s)]\n\nwill be simplified to:\n\n\ts[a:]\n\nThis is one of the simplifications that \"gofmt -s\" applies.\n\nThis analyzer ignores generated code.", |
| "default": true |
| }, |
| "slog": { |
| "type": "boolean", |
| "markdownDescription": "check for invalid structured logging calls\n\nThe slog checker looks for calls to functions from the log/slog\npackage that take alternating key-value pairs. It reports calls\nwhere an argument in a key position is neither a string nor a\nslog.Attr, and where a final key is missing its value.\nFor example,it would report\n\n\tslog.Warn(\"message\", 11, \"k\") // slog.Warn arg \"11\" should be a string or a slog.Attr\n\nand\n\n\tslog.Info(\"message\", \"k1\", v1, \"k2\") // call to slog.Info missing a final value", |
| "default": true |
| }, |
| "sortslice": { |
| "type": "boolean", |
| "markdownDescription": "check the argument type of sort.Slice\n\nsort.Slice requires an argument of a slice type. Check that\nthe interface{} value passed to sort.Slice is actually a slice.", |
| "default": true |
| }, |
| "stdmethods": { |
| "type": "boolean", |
| "markdownDescription": "check signature of methods of well-known interfaces\n\nSometimes a type may be intended to satisfy an interface but may fail to\ndo so because of a mistake in its method signature.\nFor example, the result of this WriteTo method should be (int64, error),\nnot error, to satisfy io.WriterTo:\n\n\ttype myWriterTo struct{...}\n\tfunc (myWriterTo) WriteTo(w io.Writer) error { ... }\n\nThis check ensures that each method whose name matches one of several\nwell-known interface methods from the standard library has the correct\nsignature for that interface.\n\nChecked method names include:\n\n\tFormat GobEncode GobDecode MarshalJSON MarshalXML\n\tPeek ReadByte ReadFrom ReadRune Scan Seek\n\tUnmarshalJSON UnreadByte UnreadRune WriteByte\n\tWriteTo", |
| "default": true |
| }, |
| "stdversion": { |
| "type": "boolean", |
| "markdownDescription": "report uses of too-new standard library symbols\n\nThe stdversion analyzer reports references to symbols in the standard\nlibrary that were introduced by a Go release higher than the one in\nforce in the referring file. (Recall that the file's Go version is\ndefined by the 'go' directive its module's go.mod file, or by a\n\"//go:build go1.X\" build tag at the top of the file.)\n\nThe analyzer does not report a diagnostic for a reference to a \"too\nnew\" field or method of a type that is itself \"too new\", as this may\nhave false positives, for example if fields or methods are accessed\nthrough a type alias that is guarded by a Go version constraint.\n", |
| "default": true |
| }, |
| "stringintconv": { |
| "type": "boolean", |
| "markdownDescription": "check for string(int) conversions\n\nThis checker flags conversions of the form string(x) where x is an integer\n(but not byte or rune) type. Such conversions are discouraged because they\nreturn the UTF-8 representation of the Unicode code point x, and not a decimal\nstring representation of x as one might expect. Furthermore, if x denotes an\ninvalid code point, the conversion cannot be statically rejected.\n\nFor conversions that intend on using the code point, consider replacing them\nwith string(rune(x)). Otherwise, strconv.Itoa and its equivalents return the\nstring representation of the value in the desired base.", |
| "default": true |
| }, |
| "structtag": { |
| "type": "boolean", |
| "markdownDescription": "check that struct field tags conform to reflect.StructTag.Get\n\nAlso report certain struct tags (json, xml) used with unexported fields.", |
| "default": true |
| }, |
| "testinggoroutine": { |
| "type": "boolean", |
| "markdownDescription": "report calls to (*testing.T).Fatal from goroutines started by a test\n\nFunctions that abruptly terminate a test, such as the Fatal, Fatalf, FailNow, and\nSkip{,f,Now} methods of *testing.T, must be called from the test goroutine itself.\nThis checker detects calls to these functions that occur within a goroutine\nstarted by the test. For example:\n\n\tfunc TestFoo(t *testing.T) {\n\t go func() {\n\t t.Fatal(\"oops\") // error: (*T).Fatal called from non-test goroutine\n\t }()\n\t}", |
| "default": true |
| }, |
| "tests": { |
| "type": "boolean", |
| "markdownDescription": "check for common mistaken usages of tests and examples\n\nThe tests checker walks Test, Benchmark, Fuzzing and Example functions checking\nmalformed names, wrong signatures and examples documenting non-existent\nidentifiers.\n\nPlease see the documentation for package testing in golang.org/pkg/testing\nfor the conventions that are enforced for Tests, Benchmarks, and Examples.", |
| "default": true |
| }, |
| "timeformat": { |
| "type": "boolean", |
| "markdownDescription": "check for calls of (time.Time).Format or time.Parse with 2006-02-01\n\nThe timeformat checker looks for time formats with the 2006-02-01 (yyyy-dd-mm)\nformat. Internationally, \"yyyy-dd-mm\" does not occur in common calendar date\nstandards, and so it is more likely that 2006-01-02 (yyyy-mm-dd) was intended.", |
| "default": true |
| }, |
| "unmarshal": { |
| "type": "boolean", |
| "markdownDescription": "report passing non-pointer or non-interface values to unmarshal\n\nThe unmarshal analysis reports calls to functions such as json.Unmarshal\nin which the argument type is not a pointer or an interface.", |
| "default": true |
| }, |
| "unreachable": { |
| "type": "boolean", |
| "markdownDescription": "check for unreachable code\n\nThe unreachable analyzer finds statements that execution can never reach\nbecause they are preceded by a return statement, a call to panic, an\ninfinite loop, or similar constructs.", |
| "default": true |
| }, |
| "unsafeptr": { |
| "type": "boolean", |
| "markdownDescription": "check for invalid conversions of uintptr to unsafe.Pointer\n\nThe unsafeptr analyzer reports likely incorrect uses of unsafe.Pointer\nto convert integers to pointers. A conversion from uintptr to\nunsafe.Pointer is invalid if it implies that there is a uintptr-typed\nword in memory that holds a pointer value, because that word will be\ninvisible to stack copying and to the garbage collector.", |
| "default": true |
| }, |
| "unusedfunc": { |
| "type": "boolean", |
| "markdownDescription": "check for unused functions and methods\n\nThe unusedfunc analyzer reports functions and methods that are\nnever referenced outside of their own declaration.\n\nA function is considered unused if it is unexported and not\nreferenced (except within its own declaration).\n\nA method is considered unused if it is unexported, not referenced\n(except within its own declaration), and its name does not match\nthat of any method of an interface type declared within the same\npackage.\n\nThe tool may report false positives in some situations, for\nexample:\n\n - For a declaration of an unexported function that is referenced\n from another package using the go:linkname mechanism, if the\n declaration's doc comment does not also have a go:linkname\n comment.\n\n (Such code is in any case strongly discouraged: linkname\n annotations, if they must be used at all, should be used on both\n the declaration and the alias.)\n\n - For compiler intrinsics in the \"runtime\" package that, though\n never referenced, are known to the compiler and are called\n indirectly by compiled object code.\n\n - For functions called only from assembly.\n\n - For functions called only from files whose build tags are not\n selected in the current build configuration.\n\nSee https://github.com/golang/go/issues/71686 for discussion of\nthese limitations.\n\nThe unusedfunc algorithm is not as precise as the\ngolang.org/x/tools/cmd/deadcode tool, but it has the advantage that\nit runs within the modular analysis framework, enabling near\nreal-time feedback within gopls.", |
| "default": true |
| }, |
| "unusedparams": { |
| "type": "boolean", |
| "markdownDescription": "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 ensure soundness, it ignores:\n - \"address-taken\" functions, that is, functions that are used as\n a value rather than being called directly; their signatures may\n be required to conform to a func type.\n - exported functions or methods, since they may be address-taken\n in another package.\n - unexported methods whose name matches an interface method\n declared in the same package, since the method's signature\n may be required to conform to the interface type.\n - functions with empty bodies, or containing just a call to panic.\n - parameters that are unnamed, or named \"_\", the blank identifier.\n\nThe analyzer suggests a fix of replacing the parameter name by \"_\",\nbut in such cases a deeper fix can be obtained by invoking the\n\"Refactor: remove unused parameter\" code action, which will\neliminate the parameter entirely, along with all corresponding\narguments at call sites, while taking care to preserve any side\neffects in the argument expressions; see\nhttps://github.com/golang/tools/releases/tag/gopls%2Fv0.14.\n\nThis analyzer ignores generated code.", |
| "default": true |
| }, |
| "unusedresult": { |
| "type": "boolean", |
| "markdownDescription": "check for unused results of calls to some functions\n\nSome functions like fmt.Errorf return a result and have no side\neffects, so it is always a mistake to discard the result. Other\nfunctions may return an error that must not be ignored, or a cleanup\noperation that must be called. This analyzer reports calls to\nfunctions like these when the result of the call is ignored.\n\nThe set of functions may be controlled using flags.", |
| "default": true |
| }, |
| "unusedvariable": { |
| "type": "boolean", |
| "markdownDescription": "check for unused variables and suggest fixes", |
| "default": true |
| }, |
| "unusedwrite": { |
| "type": "boolean", |
| "markdownDescription": "checks for unused writes\n\nThe analyzer reports instances of writes to struct fields and\narrays that are never read. Specifically, when a struct object\nor an array is copied, its elements are copied implicitly by\nthe compiler, and any element write to this copy does nothing\nwith the original object.\n\nFor example:\n\n\ttype T struct { x int }\n\n\tfunc f(input []T) {\n\t\tfor i, v := range input { // v is a copy\n\t\t\tv.x = i // unused write to field x\n\t\t}\n\t}\n\nAnother example is about non-pointer receiver:\n\n\ttype T struct { x int }\n\n\tfunc (t T) f() { // t is a copy\n\t\tt.x = i // unused write to field x\n\t}", |
| "default": true |
| }, |
| "waitgroup": { |
| "type": "boolean", |
| "markdownDescription": "check for misuses of sync.WaitGroup\n\nThis analyzer detects mistaken calls to the (*sync.WaitGroup).Add\nmethod from inside a new goroutine, causing Add to race with Wait:\n\n\t// WRONG\n\tvar wg sync.WaitGroup\n\tgo func() {\n\t wg.Add(1) // \"WaitGroup.Add called from inside new goroutine\"\n\t defer wg.Done()\n\t ...\n\t}()\n\twg.Wait() // (may return prematurely before new goroutine starts)\n\nThe correct code calls Add before starting the goroutine:\n\n\t// RIGHT\n\tvar wg sync.WaitGroup\n\twg.Add(1)\n\tgo func() {\n\t\tdefer wg.Done()\n\t\t...\n\t}()\n\twg.Wait()", |
| "default": true |
| }, |
| "yield": { |
| "type": "boolean", |
| "markdownDescription": "report calls to yield where the result is ignored\n\nAfter a yield function returns false, the caller should not call\nthe yield function again; generally the iterator should return\npromptly.\n\nThis example fails to check the result of the call to yield,\ncausing this analyzer to report a diagnostic:\n\n\tyield(1) // yield may be called again (on L2) after returning false\n\tyield(2)\n\nThe corrected code is either this:\n\n\tif yield(1) { yield(2) }\n\nor simply:\n\n\t_ = yield(1) && yield(2)\n\nIt is not always a mistake to ignore the result of yield.\nFor example, this is a valid single-element iterator:\n\n\tyield(1) // ok to ignore result\n\treturn\n\nIt is only a mistake when the yield call that returned false may be\nfollowed by another call.", |
| "default": true |
| } |
| } |
| }, |
| "ui.diagnostic.analysisProgressReporting": { |
| "type": "boolean", |
| "markdownDescription": "analysisProgressReporting controls whether gopls sends progress\nnotifications when construction of its index of analysis facts is taking a\nlong time. Cancelling these notifications will cancel the indexing task,\nthough it will restart after the next change in the workspace.\n\nWhen a package is opened for the first time and heavyweight analyses such as\nstaticcheck are enabled, it can take a while to construct the index of\nanalysis facts for all its dependencies. The index is cached in the\nfilesystem, so subsequent analysis should be faster.\n", |
| "default": true, |
| "scope": "resource" |
| }, |
| "ui.diagnostic.annotations": { |
| "type": "object", |
| "markdownDescription": "annotations specifies the various kinds of compiler\noptimization details that should be reported as diagnostics\nwhen enabled for a package by the \"Toggle compiler\noptimization details\" (`gopls.gc_details`) command.\n\n(Some users care only about one kind of annotation in their\nprofiling efforts. More importantly, in large packages, the\nnumber of annotations can sometimes overwhelm the user\ninterface and exceed the per-file diagnostic limit.)\n\nTODO(adonovan): rename this field to CompilerOptDetail.\n", |
| "scope": "resource", |
| "properties": { |
| "bounds": { |
| "type": "boolean", |
| "markdownDescription": "`\"bounds\"` controls bounds checking diagnostics.\n", |
| "default": true |
| }, |
| "escape": { |
| "type": "boolean", |
| "markdownDescription": "`\"escape\"` controls diagnostics about escape choices.\n", |
| "default": true |
| }, |
| "inline": { |
| "type": "boolean", |
| "markdownDescription": "`\"inline\"` controls diagnostics about inlining choices.\n", |
| "default": true |
| }, |
| "nil": { |
| "type": "boolean", |
| "markdownDescription": "`\"nil\"` controls nil checks.\n", |
| "default": true |
| } |
| } |
| }, |
| "ui.diagnostic.diagnosticsDelay": { |
| "type": "string", |
| "markdownDescription": "(Advanced) 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": "1s", |
| "scope": "resource" |
| }, |
| "ui.diagnostic.diagnosticsTrigger": { |
| "type": "string", |
| "markdownDescription": "(Experimental) diagnosticsTrigger controls when to run diagnostics.\n", |
| "enum": [ |
| "Edit", |
| "Save" |
| ], |
| "markdownEnumDescriptions": [ |
| "`\"Edit\"`: Trigger diagnostics on file edit and save. (default)\n", |
| "`\"Save\"`: Trigger diagnostics only on file save. Events like initial workspace load\nor configuration change will still trigger diagnostics.\n" |
| ], |
| "default": "Edit", |
| "scope": "resource" |
| }, |
| "ui.diagnostic.staticcheck": { |
| "type": "boolean", |
| "markdownDescription": "(Experimental) staticcheck configures the default set of analyses staticcheck.io.\nThese analyses are documented on\n[Staticcheck's website](https://staticcheck.io/docs/checks/).\n\nThe \"staticcheck\" option has three values:\n- false: disable all staticcheck analyzers\n- true: enable all staticcheck analyzers\n- unset: enable a subset of staticcheck analyzers\n selected by gopls maintainers for runtime efficiency\n and analytic precision.\n\nRegardless of this setting, individual analyzers can be\nselectively enabled or disabled using the `analyses` setting.\n", |
| "default": false, |
| "scope": "resource" |
| }, |
| "ui.diagnostic.staticcheckProvided": { |
| "type": "boolean", |
| "markdownDescription": "(Experimental) ", |
| "default": false, |
| "scope": "resource" |
| }, |
| "ui.documentation.hoverKind": { |
| "type": "string", |
| "markdownDescription": "hoverKind controls the information that appears in the hover text.\nSingleLine is intended for use only by authors of editor plugins.\n", |
| "enum": [ |
| "FullDocumentation", |
| "NoDocumentation", |
| "SingleLine", |
| "Structured", |
| "SynopsisDocumentation" |
| ], |
| "markdownEnumDescriptions": [ |
| "", |
| "", |
| "", |
| "`\"Structured\"` is a misguided experimental setting that returns a JSON\nhover format. This setting should not be used, as it will be removed in a\nfuture release of gopls.\n", |
| "" |
| ], |
| "default": "FullDocumentation", |
| "scope": "resource" |
| }, |
| "ui.documentation.linkTarget": { |
| "type": "string", |
| "markdownDescription": "linkTarget is the base URL for links to Go package\ndocumentation returned by LSP operations such as Hover and\nDocumentLinks and in the CodeDescription field of each\nDiagnostic.\n\nIt might be one of:\n\n* `\"godoc.org\"`\n* `\"pkg.go.dev\"`\n\nIf company chooses to use its own `godoc.org`, its address can be used as well.\n\nModules matching the GOPRIVATE environment variable will not have\ndocumentation links in hover.\n", |
| "default": "pkg.go.dev", |
| "scope": "resource" |
| }, |
| "ui.documentation.linksInHover": { |
| "type": [ |
| "boolean", |
| "string" |
| ], |
| "markdownDescription": "linksInHover controls the presence of documentation links in hover markdown.\n", |
| "enum": [ |
| false, |
| true, |
| "gopls" |
| ], |
| "markdownEnumDescriptions": [ |
| "false: do not show links", |
| "true: show links to the `linkTarget` domain", |
| "`\"gopls\"`: show links to gopls' internal documentation viewer" |
| ], |
| "default": true, |
| "scope": "resource" |
| }, |
| "ui.navigation.importShortcut": { |
| "type": "string", |
| "markdownDescription": "importShortcut specifies whether import statements should link to\ndocumentation or go to definitions.\n", |
| "enum": [ |
| "Both", |
| "Definition", |
| "Link" |
| ], |
| "markdownEnumDescriptions": [ |
| "", |
| "", |
| "" |
| ], |
| "default": "Both", |
| "scope": "resource" |
| }, |
| "ui.navigation.symbolMatcher": { |
| "type": "string", |
| "markdownDescription": "(Advanced) symbolMatcher sets the algorithm that is used when finding workspace symbols.\n", |
| "enum": [ |
| "CaseInsensitive", |
| "CaseSensitive", |
| "FastFuzzy", |
| "Fuzzy" |
| ], |
| "markdownEnumDescriptions": [ |
| "", |
| "", |
| "", |
| "" |
| ], |
| "default": "FastFuzzy", |
| "scope": "resource" |
| }, |
| "ui.navigation.symbolScope": { |
| "type": "string", |
| "markdownDescription": "symbolScope controls which packages are searched for workspace/symbol\nrequests. When the scope is \"workspace\", gopls searches only workspace\npackages. When the scope is \"all\", gopls searches all loaded packages,\nincluding dependencies and the standard library.\n", |
| "enum": [ |
| "all", |
| "workspace" |
| ], |
| "markdownEnumDescriptions": [ |
| "`\"all\"` matches symbols in any loaded package, including\ndependencies.\n", |
| "`\"workspace\"` matches symbols in workspace packages only.\n" |
| ], |
| "default": "all", |
| "scope": "resource" |
| }, |
| "ui.navigation.symbolStyle": { |
| "type": "string", |
| "markdownDescription": "(Advanced) 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", |
| "enum": [ |
| "Dynamic", |
| "Full", |
| "Package" |
| ], |
| "markdownEnumDescriptions": [ |
| "`\"Dynamic\"` uses whichever qualifier results in the highest scoring\nmatch for the given symbol query. Here a \"qualifier\" is any \"/\" or \".\"\ndelimited suffix of the fully qualified symbol. i.e. \"to/pkg.Foo.Field\" or\njust \"Foo.Field\".\n", |
| "`\"Full\"` is fully qualified symbols, i.e.\n\"path/to/pkg.Foo.Field\".\n", |
| "`\"Package\"` is package qualified symbols i.e.\n\"pkg.Foo.Field\".\n" |
| ], |
| "default": "Dynamic", |
| "scope": "resource" |
| }, |
| "ui.noSemanticNumber": { |
| "type": "boolean", |
| "markdownDescription": "(Experimental) noSemanticNumber turns off the sending of the semantic token 'number'\n\nDeprecated: Use SemanticTokenTypes[\"number\"] = false instead. See\ngolang/vscode-go#3632.\n", |
| "default": false, |
| "scope": "resource", |
| "deprecationMessage": "use SemanticTokenTypes[\"number\"] = false instead. See\ngolang/vscode-go#3632.\n" |
| }, |
| "ui.noSemanticString": { |
| "type": "boolean", |
| "markdownDescription": "(Experimental) noSemanticString turns off the sending of the semantic token 'string'\n\nDeprecated: Use SemanticTokenTypes[\"string\"] = false instead. See\ngolang/vscode-go#3632\n", |
| "default": false, |
| "scope": "resource", |
| "deprecationMessage": "use SemanticTokenTypes[\"string\"] = false instead. See\ngolang/vscode-go#3632\n" |
| }, |
| "ui.semanticTokenModifiers": { |
| "type": "object", |
| "markdownDescription": "(Experimental) semanticTokenModifiers configures the semantic token modifiers. It allows\ndisabling modifiers by setting each value to false.\nBy default, all modifiers are enabled.\n", |
| "scope": "resource" |
| }, |
| "ui.semanticTokenTypes": { |
| "type": "object", |
| "markdownDescription": "(Experimental) semanticTokenTypes configures the semantic token types. It allows\ndisabling types by setting each value to false.\nBy default, all types are enabled.\n", |
| "scope": "resource" |
| }, |
| "ui.semanticTokens": { |
| "type": "boolean", |
| "markdownDescription": "(Experimental) semanticTokens controls whether the LSP server will send\nsemantic tokens to the client.\n", |
| "default": false, |
| "scope": "resource" |
| }, |
| "verboseOutput": { |
| "type": "boolean", |
| "markdownDescription": "(For Debugging) verboseOutput enables additional debug logging.\n", |
| "default": false, |
| "scope": "resource" |
| } |
| } |
| }, |
| "go.diagnostic.vulncheck": { |
| "type": "string", |
| "markdownDescription": "(Experimental) vulncheck enables vulnerability scanning.\n", |
| "enum": [ |
| "Imports", |
| "Off" |
| ], |
| "markdownEnumDescriptions": [ |
| "`\"Imports\"`: In Imports mode, `gopls` will report vulnerabilities that affect packages\ndirectly and indirectly used by the analyzed main module.\n", |
| "`\"Off\"`: Disable vulnerability analysis.\n" |
| ], |
| "default": "Off", |
| "scope": "resource" |
| }, |
| "go.inlayHints.assignVariableTypes": { |
| "type": "boolean", |
| "markdownDescription": "`\"assignVariableTypes\"` controls inlay hints for variable types in assign statements:\n```go\n\ti/* int*/, j/* int*/ := 0, len(r)-1\n```\n", |
| "default": false |
| }, |
| "go.inlayHints.compositeLiteralFields": { |
| "type": "boolean", |
| "markdownDescription": "`\"compositeLiteralFields\"` inlay hints for composite literal field names:\n```go\n\t{/*in: */\"Hello, world\", /*want: */\"dlrow ,olleH\"}\n```\n", |
| "default": false |
| }, |
| "go.inlayHints.compositeLiteralTypes": { |
| "type": "boolean", |
| "markdownDescription": "`\"compositeLiteralTypes\"` controls inlay hints for composite literal types:\n```go\n\tfor _, c := range []struct {\n\t\tin, want string\n\t}{\n\t\t/*struct{ in string; want string }*/{\"Hello, world\", \"dlrow ,olleH\"},\n\t}\n```\n", |
| "default": false |
| }, |
| "go.inlayHints.constantValues": { |
| "type": "boolean", |
| "markdownDescription": "`\"constantValues\"` controls inlay hints for constant values:\n```go\n\tconst (\n\t\tKindNone Kind = iota/* = 0*/\n\t\tKindPrint/* = 1*/\n\t\tKindPrintf/* = 2*/\n\t\tKindErrorf/* = 3*/\n\t)\n```\n", |
| "default": false |
| }, |
| "go.inlayHints.functionTypeParameters": { |
| "type": "boolean", |
| "markdownDescription": "`\"functionTypeParameters\"` inlay hints for implicit type parameters on generic functions:\n```go\n\tmyFoo/*[int, string]*/(1, \"hello\")\n```\n", |
| "default": false |
| }, |
| "go.inlayHints.parameterNames": { |
| "type": "boolean", |
| "markdownDescription": "`\"parameterNames\"` controls inlay hints for parameter names:\n```go\n\tparseInt(/* str: */ \"123\", /* radix: */ 8)\n```\n", |
| "default": false |
| }, |
| "go.inlayHints.rangeVariableTypes": { |
| "type": "boolean", |
| "markdownDescription": "`\"rangeVariableTypes\"` controls inlay hints for variable types in range statements:\n```go\n\tfor k/* int*/, v/* string*/ := range []string{} {\n\t\tfmt.Println(k, v)\n\t}\n```\n", |
| "default": false |
| } |
| } |
| }, |
| "menus": { |
| "commandPalette": [ |
| { |
| "command": "go.test.refresh", |
| "when": "false" |
| }, |
| { |
| "command": "go.test.showProfiles", |
| "when": "false" |
| }, |
| { |
| "command": "go.test.captureProfile", |
| "when": "false" |
| }, |
| { |
| "command": "go.test.deleteProfile", |
| "when": "false" |
| }, |
| { |
| "command": "go.test.showProfileFile", |
| "when": "false" |
| }, |
| { |
| "command": "go.explorer.refresh", |
| "when": "false" |
| }, |
| { |
| "command": "go.explorer.open", |
| "when": "false" |
| } |
| ], |
| "debug/callstack/context": [ |
| { |
| "command": "go.debug.toggleHideSystemGoroutines", |
| "when": "debugType == 'go' && callStackItemType == 'stackFrame' || (callStackItemType == 'thread' && callStackItemStopped)" |
| } |
| ], |
| "editor/context": [ |
| { |
| "when": "editorTextFocus && config.go.editorContextMenuCommands.toggleTestFile && resourceLangId == go", |
| "command": "go.toggle.test.file", |
| "group": "Go group 1" |
| }, |
| { |
| "when": "editorTextFocus && config.go.editorContextMenuCommands.addTags && resourceLangId == go", |
| "command": "go.add.tags", |
| "group": "Go group 1" |
| }, |
| { |
| "when": "editorTextFocus && config.go.editorContextMenuCommands.removeTags && resourceLangId == go", |
| "command": "go.remove.tags", |
| "group": "Go group 1" |
| }, |
| { |
| "when": "editorTextFocus && config.go.editorContextMenuCommands.testAtCursor && resourceLangId == go", |
| "command": "go.test.cursor", |
| "group": "Go group 1" |
| }, |
| { |
| "when": "editorTextFocus && config.go.editorContextMenuCommands.benchmarkAtCursor && resourceLangId == go", |
| "command": "go.benchmark.cursor", |
| "group": "Go group 1" |
| }, |
| { |
| "when": "editorTextFocus && config.go.editorContextMenuCommands.debugTestAtCursor && resourceLangId == go", |
| "command": "go.debug.cursor", |
| "group": "Go group 1" |
| }, |
| { |
| "when": "editorTextFocus && config.go.editorContextMenuCommands.testFile && resourceLangId == go", |
| "command": "go.test.file", |
| "group": "Go group 1" |
| }, |
| { |
| "when": "editorTextFocus && config.go.editorContextMenuCommands.testPackage && resourceLangId == go", |
| "command": "go.test.package", |
| "group": "Go group 1" |
| }, |
| { |
| "when": "editorTextFocus && config.go.editorContextMenuCommands.generateTestForFunction && resourceLangId == go", |
| "command": "go.test.generate.function", |
| "group": "Go group 1" |
| }, |
| { |
| "when": "editorTextFocus && config.go.editorContextMenuCommands.generateTestForFile && resourceLangId == go", |
| "command": "go.test.generate.file", |
| "group": "Go group 1" |
| }, |
| { |
| "when": "editorTextFocus && config.go.editorContextMenuCommands.generateTestForPackage && resourceLangId == go", |
| "command": "go.test.generate.package", |
| "group": "Go group 1" |
| }, |
| { |
| "when": "editorTextFocus && config.go.editorContextMenuCommands.addImport && resourceLangId == go", |
| "command": "go.import.add", |
| "group": "Go group 1" |
| }, |
| { |
| "when": "editorTextFocus && config.go.editorContextMenuCommands.testCoverage && resourceLangId == go", |
| "command": "go.test.coverage", |
| "group": "Go group 1" |
| }, |
| { |
| "when": "editorTextFocus && config.go.editorContextMenuCommands.playground && resourceLangId == go", |
| "command": "go.playground", |
| "group": "Go group 1" |
| }, |
| { |
| "when": "editorTextFocus && resourceLangId == go", |
| "command": "go.show.commands", |
| "group": "Go group 2" |
| } |
| ], |
| "testing/item/context": [ |
| { |
| "command": "go.test.refresh", |
| "when": "testId in go.tests", |
| "group": "inline" |
| }, |
| { |
| "command": "go.test.showProfiles", |
| "when": "testId in go.profiledTests", |
| "group": "profile" |
| }, |
| { |
| "command": "go.test.captureProfile", |
| "when": "testId in go.tests && testId =~ /\\?(test|benchmark)/", |
| "group": "profile" |
| } |
| ], |
| "view/title": [ |
| { |
| "command": "go.explorer.refresh", |
| "when": "view == go.explorer", |
| "group": "navigation" |
| } |
| ], |
| "view/item/context": [ |
| { |
| "command": "go.test.deleteProfile", |
| "when": "viewItem == go:test:file" |
| }, |
| { |
| "command": "go.explorer.open", |
| "when": "viewItem == go:explorer:envfile", |
| "group": "inline" |
| }, |
| { |
| "command": "go.workspace.editEnv", |
| "when": "viewItem =~ /(go:explorer:envtree|go:explorer:envitem)/ && workspaceFolderCount > 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" |
| }, |
| { |
| "id": "go.package.outline", |
| "name": "Package Outline", |
| "icon": "media/go-logo-white.svg", |
| "when": "go.showPackageOutline" |
| } |
| ], |
| "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\"." |
| } |
| } |
| } |
| } |
| } |
| ] |
| } |
| } |