Skip to content

Latest commit

 

History

History
195 lines (102 loc) · 8.18 KB

commands.md

File metadata and controls

195 lines (102 loc) · 8.18 KB

Commands

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).

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:.

Latest changes

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:

  1. Navigate to the Extensions view (Ctrl+Shift+X).
  2. Find the Go extension and click on it to open the Extension Editor.
  3. Click on the Feature Contributions tab.
  4. Scroll through the list under Commands.

Finally, you can also see a full list by using a meta command: Go: Show All Commands....

Detailed list

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).

Code editing and generation

Manually add an import to your file. See Add import.

[Go: Add Package to Workspace]

Add a package to the current workspace.

Automatically generate tags for your struct. See Add or remove struct tags.

Removes tags from the selected struct fields. See Add or remove struct tags.

Fill a struct literal with default values. See Fill struct.

Generate method stubs for given interface. See Generate interface implementation.

Generate unit tests for the selected function in the current file. See Generate unit tests.

Generate unit tests for the current file. See Generate unit tests.

Generate unit tests for the current package. See Generate unit tests.

Extract the highlighted code to a function. Provided by the godoctor tool. Learn more about refactoring.

Extract the highlighted code to a local variable. Provided by the godoctor tool. Learn more about refactoring.

Testing and benchmarking

Run the test function at the current cursor position in the file.

Run the subtest (t.Run) at the current cursor position in the file.

Run the benchmark at the current cursor position in the file.

Debug the test at the current cursor position.

Run all of the tests in the current file.

Run all of the benchmarks in the current file.

Run all of the tests in the current package.

Run all of the benchmarks in the current package.

Re-run the most recently executed test command.

Run all of the tests in the current workspace.

Cancel currently running tests.

Toggle between a file and its corresponding test file.

Apply a given cover profile to the current file.

Show code coverage in the current file.

Build, lint, and vet

Build the current package and show build errors.

Show vet errors for the current package.

Show lint errors for the current package.

Build all of the packages in the current workspace and show build errors.

Show vet errors for all of the packages in the current workspace.

Show lint errors for all of the packages in the current workspace.

Go: Install Current Package

Install the current package and its dependencies.

Miscellaneous

Use this command to restart the language server without reloading the VS Code window. This can be helpful if something seems goes wrong with the language server (for example, if you see incorrect error messages).

Upload the current selection or file to the Go Playground (play.golang.org). See Go Playground.

Troubleshooting

Go: Current GOPATH

See 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. This command is helpful when troubleshooting the extension.

Install 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.

This command is helpful when troubleshooting the extension. It prints out the environment variables and paths to the tools used by the extension. See an example of the command's output in the troubleshooting documentation.