Installing Go tools globally - Lucas Melin

Installing Go tools globally

There are several useful command-line tools in the Go ecosystem such as delve, godoc and staticcheck to name a few.

These can all be installed using Go, however there’s a slight trick to ensure that the tools are installed globally - you need to first change to a directory that is both outside of your GOPATH and outside of a module (a temp directory works fine for this). Then, you can simply use go install to install the tools like so:

go install github.com/go-delve/delve/cmd/dlv@latest
go install golang.org/x/tools/cmd/godoc
go install honnef.co/go/tools/cmd/staticcheck@latest