Installing packages in a local directory

You might want to consider using Go Version Manager (gvm).

Apart from switching between Go versions easily, it also lets you switch between pkgsets ("workspaces").

First you create a set

gvm pkgset create myproject

and then you use it

gvm pkgset use myproject

Works like a charm.


To expand on keks answer, you can update your .bashrc to look like this

export GOROOT=/usr/local/go
export GOPATH=~/workspace/me/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

Now all packages installed with go get are separate from the go distribution.


You can export the env variable GOPATH. For me it is ~/local/lib/go. This folder has the subfolders bin, pkg and src, so it's just like /usr/local/go. The go-tool will then automatically download , build and install packages into this directory.