An additional step when setting up your Go Development Environment

I am using VS Code as my IDE for Go and thought it would be worth sharing a tip I learnt about additional tools to include after the official Go extension from Google had been installed.

Bring up the command pallet (ctl + shift + p) and type:

go install/update tools

and you will be presented with the option to install a number of additional tools

Select the ones of interest or select them all, which I did.

Here is the output from VS Code showing the successful installation:

Tools environment: GOPATH=/home/go/go
Installing 7 tools at /home/go/go/bin in module mode.
  gotests
  gomodifytags
  impl
  goplay
  dlv
  staticcheck
  gopls

Installing github.com/cweill/gotests/gotests@v1.6.0 (/home/go/go/bin/gotests) SUCCEEDED
Installing github.com/fatih/gomodifytags@v1.16.0 (/home/go/go/bin/gomodifytags) SUCCEEDED
Installing github.com/josharian/impl@v1.1.0 (/home/go/go/bin/impl) SUCCEEDED
Installing github.com/haya14busa/goplay/cmd/goplay@v1.0.0 (/home/go/go/bin/goplay) SUCCEEDED
Installing github.com/go-delve/delve/cmd/dlv@latest (/home/go/go/bin/dlv) SUCCEEDED
Installing honnef.co/go/tools/cmd/staticcheck@latest (/home/go/go/bin/staticcheck) SUCCEEDED
Installing golang.org/x/tools/gopls@latest (/home/go/go/bin/gopls) SUCCEEDED

All tools successfully installed. You are ready to Go. 🙂

Problems

The extension has dependencies on several tools and if these are absent you will be prompted to download them. During the preparation of this post I ran into a problem whereby VS Code would report the following error when a Go file was opened:

Failed to run '/snap/bin/go env. The config change may not be applied correctly.

The resolution was to make a change to the VS Code JSON preferences file as described in this issue on GitHub. If you run into problems with this fix please let me know in the comments.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.