In addition to the integrated editing features, this extension offers a number of commands, which can be executed manually through the Command Palette (Ctrl+Shift+P).
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....
Below is a detailed list of commands. They are categorized into code editing and generation, testing and benchmarking, build, lint, and vet, miscellaneous, and troubleshooting. You will find the troubleshooting commands helpful when diagnosing an issue with the extension (learn more in the Troubleshooting documentation).
Go: Add ImportManually add an import to your file. See Add import.
Go: Add Package to WorkspaceGo: Add Tags to Struct FieldsAutomatically generate tags for your struct. See Add or remove struct tags.
Go: Remove Tags From Struct FieldsRemoves tags from the selected struct fields. See Add or remove struct tags.
Go: Fill structFill a struct literal with default values. See Fill struct.
Go: Generate Interface StubsGenerate method stubs for given interface. See Generate interface implementation.
Go: Generate Unit Tests For FunctionGenerate unit tests for the selected function in the current file. See Generate unit tests.
Go: Generate Unit Tests For FileGenerate unit tests for the current file. See Generate unit tests.
Go: Generate Unit Tests For PackageGenerate unit tests for the current package. See Generate unit tests.
Go: Extract to functionGo: Extract to variableGo: Test Function at CursorRun the test function at the current cursor position in the file.
Go: Subtest at CursorGo: Benchmark Function At CursorGo: Debug Test At CursorGo: Test FileRun all of the tests in the current file.
Go: Benchmark FileGo: Test PackageRun all of tests in the current package.
Go: Benchmark PackageGo: Test PreviousRe-run the most recently executed test command.
Go: Test All Packages In WorkspaceRun all of the tests in the current workspace.
Go: Toggle Test FileGo: Toggle Test Coverage In Current PackageGo: Build Current PackageGo: Lint Current PackageGo: Vet Current PackageGo: Build WorkspaceGo: Lint WorkspaceGo: Vet WorkspaceGo: Install Current PackageGo: Restart Language ServerGo: Run on Go PlaygroundUpload the current selection or file to the Go Playground (play.golang.org). See Go Playground.
Go: Current GOPATHSee the current value of GOPATH. This is not equivalent to go env GOPATH, as your VS Code settings may have altered the value of GOPATH used by the extension.
Go: Install/Update ToolsInstall or update the Go tools on which the extension depends. Tools can be installed or updated all at once, or individual tools can be selected.
Go: Locate Configured Go Tools