In addition to integrated editing features, this extension offers a number of commands, which can be executed manually through the Command Palette (Ctrl+Shift+P on Linux/Windows or Cmd+Shift+P on Mac OS).
Some of these commands are also available in the VS Code context menu (right-click). To control which of these commands show up in the editor context menu, update the "go.editorContextMenuCommands" setting.
All commands provided by this extension have the prefix Go:.
The commands described below are up-to-date as of June 2020. We do our best to keep documentation current, but if a command is missing, you can always consult the full list in the Extensions view.
To view this list:
Feature Contributions tab.Commands.Finally, you can also see a full list by using a meta command: Go: Show All Commands....
Go: Current GOPATHSee the currently set GOPATH.
Go: Current GOROOTSee the currently set GOROOT.
Go: Locate Configured Go ToolsList all the Go tools being used by this extension along with their locations.
Go: Test Function At CursorRuns a unit test at the cursor.
Go: Test Function At Cursor or Test PreviousRuns a unit test at the cursor if one is found, otherwise re-runs the last executed test.
Go: Subtest At CursorRuns a sub test at the cursor.
Go: Benchmark Function At CursorRuns a benchmark at the cursor.
Go: Debug Test At CursorDebug test at the cursor.
Go: Test FileRuns all unit tests in the current file.
Go: Test PackageRuns all unit tests in the package of the current file.
Go Test: RefreshRefresh a test in the test explorer. Only available as a context menu option in the test explorer.
Go Test: Show Last ProfileShow last captured profile
Go Test: ProfileRun a test and capture a profile
Go Test: Delete ProfileDelete selected profile
Go: Show pprof fileInternal use. Open a pprof profile file.
Go: Benchmark PackageRuns all benchmarks in the package of the current file.
Go: Benchmark FileRuns all benchmarks in the current file.
Go: Test All Packages In WorkspaceRuns all unit tests from all packages in the current workspace.
Go: Test PreviousRe-runs the last executed test.
Go: Debug PreviousRe-runs the last debugged test run through a codelens or “Go: Debug Test at Cursor” command.
Go: Toggle Test Coverage In Current PackageDisplays test coverage in the current package.
Go: Generate Unit Tests For PackageGenerates unit tests for the current package
Go: Generate Unit Tests For FileGenerates unit tests for the current file
Go: Generate Unit Tests For FunctionGenerates unit tests for the selected function in the current file
Go: Generate Interface StubsGenerates method stub for implementing the provided interface and inserts at the cursor.
Go: Extract Language Server Logs To EditorExtract logs in the gopls (server) output channel to the editor.
Go: WelcomeOpen the welcome page for the Go extension.
Go: Toggle gc detailsToggle the display of compiler optimization choices
Go: Add ImportAdd an import declaration
Go: Add Package to WorkspaceAdd a package from the imports list to the workspace.
Go: Install/Update Toolsinstall/update the required go packages
Go: Toggle Test FileToggles between file in current active editor and the corresponding test file.
Go: Add Tags To Struct FieldsAdd tags configured in go.addTags setting to selected struct using gomodifytags
Go: Remove Tags From Struct FieldsRemove tags configured in go.removeTags setting from selected struct using gomodifytags
Go: Fill structFill a struct literal with default values
Go: Show All Commands...Shows all commands from the Go extension in the quick pick
Go: Browse PackagesBrowse packages and Go files inside the packages.
Go: Get PackageRun go get -v on the package on the current line.
Go: Run on Go PlaygroundUpload the current selection or file to the Go Playground
Go: Lint Current PackageRun linter in the package of the current file.
Go: Lint WorkspaceRun linter in the current workspace.
Go: Vet Current PackageRun go vet in the package of the current file.
Go: Vet WorkspaceRun go vet in the current workspace.
Go: Build Current PackageBuild the package of the current file.
Go: Build WorkspaceBuild the current workspace.
Go: Install Current PackageInstall the current package.
Go: Initialize go.modRun go mod init in the workspace folder.
Go: Cancel Running TestsCancels running tests.
Go: Apply Cover ProfileApplies existing cover profile.
Go: Extract to functionExtract to function using godoctor.
Go: Extract to variableExtract to variable using godoctor.
Go: Restart Language ServerRestart the running instance of the language server
Go: Choose Go EnvironmentChoose a different Go version or binary for this project. (WIP)
Go: Show Survey ConfigurationShow the current Go survey configuration
Go: Reset Survey ConfigurationReset the current Go survey configuration history
Go: Reset Workspace StateReset keys in workspace state to undefined.
Go: Reset Global StateReset keys in global state to undefined.
Go Explorer: RefreshRefresh the Go explorer. Only available as a menu item in the explorer.
Go Explorer: Open FileOpen a file from the Go explorer. Only available as a menu item in the explorer.
Go: Edit Workspace EnvEdit the Go Env for the active workspace.
Go: Reset Workspace EnvReset the Go Env for the active workspace.
Go: Run Vulncheck (Preview)Run vulnerability check. See https://pkg.go.dev/golang.org/x/vuln/cmd/govulncheck for more details about the analysis.