Install Golang with Homebrew

$ brew update && brew upgrade
$ brew install go

Install Mercurial (optional)

I’m not sure if Mercurial is strictly required, but may be useful for fetching packages from certain Mercurial repositories:

$ brew install hg

Set $GOPATH and add to path

In the world of Golang, all your Go projects live in a single directory which is specified by the GOPATH environment variable. This is quite different from development environments in other languages, but you should get used to it.

If you’re not sure where to put your GOPATH, I’d suggest putting it in the home directory:

Create the directory:

$ mkdir ~/golang

Then add these lines:

set -x GOPATH ~/golang # the -x flag exports the variable

to your (or create one in ~/.config/fish/ if it doesn’t exist).


Boot up a new shell and type env to check your environment variables. Your path should contain both