The Path to Go
In order to work with Go packages, one will need to setup a GOPATH
environment variable which contains the path to the directory one intents to
use with Go.
After specifying the GOPATH variable, don’t forget to append $GOPATH/bin
to PATH.
For my different go projects, I often specify a GOPATH directory within my
project’s working directory. This way I can keep my GOPATH’s for different
projects separated.
Imagine the project spaceship-api stored at /path/spaceship.
I tend to setup a gopath directory at /path/spaceship/gopath, while I park
the api repository in /path/spaceship/api. Before getting started, I
basically do the following:
export GOPATH=/path/spacechip/gopath
export PATH=$PATH:$GOPATH/bin
Now I can access all binaries within the $GOPATH/bin directory, and perform
go get commands without putting much thought into other projects that I may
be screwing up.