But as you need to install packages, you need root permission to install packages into the default system GOROOT path (like /usr/local or /opt/local.. etc)
You can provide your own GOPATH to avoid this kind of problem.
First, you should create a directory structure like this:
Then, export this path (~/mygo) to your GOPATH in your .bashrc or .zshrc file:
~/mygo ~/mygo/pkg ~/mygo/src ~/mygo/bin
And the bin path of Go:
Done. Now you can install packages into your own local go environment. for example:
which won't require you to sudo.
go get https://bitbucket.org/mikespook/gearman-go
If you need to install packages from local, you need to move your package source to ~/mygo/src directory, then build the package there, or Go will complain about
go install: no install location for ...