First, the Go extension for Visual Studio Code requires the Go tools to be already installed.
See Go's installation guide and ensure the go
command is available from your PATH
.
The Go extension for Visual Studio Code offers extra Go tools that are installed in the user's GOPATH. Some of them are responsible for general language features like code navigation, auto-completions, symbol search etc. Others, while helpful, are optional for the Go extension to provide day-to-day language support.
Below are the tools essential for the general features of this extension. If you have chosen to use the Go language server, then most of the below tools are no longer needed as the corresponding features will be provided by the language server. Eventually, once the language server is stable, we will move to using it and deprecate the use of individual tools below.
NOTE: If you are using Go modules, then we strongly recommend using the Go language server as it performs much better than the tools below.
- gocode for auto-completion
- go-outline for symbol search in the current file
- go-symbols for symbol search in the current workspace
- gopkgs for auto-completion of unimported packages
- guru for the
Find all References
feature - gorename for renaming symbols
- goreturns or goimports for formatting code (not needed if using language server)
- godef or gogetdoc for the
Go to Definition
feature (not needed if using language server) - godoc or gogetdoc for the documentation that appears on hover (not needed if using language server)
- golint or megacheck or golangci-lint or revive for linting
- dlv for debugging
If any of these tools are missing, you will see an "Analysis Tools Missing" warning in the bottom right corner of the editor. Clicking it will offer to install the missing tools for you.
There are other features of this extension which you most probably wouldn't be using every day. For eg: Generating unit tests or generating stubs for interface or modify tags. The tools used for such features are:
- gomodifytags for modifying tags on structs
- goplay for running current file in the Go playground
- impl for generating stubs for interfaces
- gotype-live for providing diagnostics as you type
- gotests for generating unit tests
- fillstruct for filling a struct literal with default values
You can install all these tools at once by running the command Go: Install/Update Tools
. The same command can be used to keep the tools up to date as well as to re-compile in case you change the version of Go being used.
If you wish to have the extension use a separate GOPATH for its tools, provide the desired location in the setting go.toolsGopath
.