Skip to content
This repository was archived by the owner on Jul 15, 2023. It is now read-only.

Go tools that the Go extension depends on

Ramya Rao edited this page Sep 14, 2019 · 36 revisions

The Go extension for Visual Studio Code offers various 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 (not needed if using language server)
  • 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
  • go-langserver for using the Go language server by Sourcegraph
  • 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.

To install the tools manually in the current GOPATH, just copy the below (after choosing the tools) in your terminal run:

go get -u -v github.com/ramya-rao-a/go-outline
go get -u -v github.com/acroca/go-symbols
go get -u -v github.com/mdempsky/gocode
go get -u -v github.com/rogpeppe/godef
go get -u -v golang.org/x/tools/cmd/godoc
go get -u -v github.com/zmb3/gogetdoc
go get -u -v golang.org/x/lint/golint
go get -u -v github.com/fatih/gomodifytags
go get -u -v golang.org/x/tools/cmd/gorename
go get -u -v sourcegraph.com/sqs/goreturns
go get -u -v golang.org/x/tools/cmd/goimports
go get -u -v github.com/cweill/gotests/...
go get -u -v golang.org/x/tools/cmd/guru
go get -u -v github.com/josharian/impl
go get -u -v github.com/haya14busa/goplay/cmd/goplay
go get -u -v github.com/uudashr/gopkgs/cmd/gopkgs
go get -u -v github.com/davidrjenni/reftools/cmd/fillstruct
gometalinter --install

And for debugging:

Clone this wiki locally