Skip to content

Setting up Golang with Fish and Homebrew

Posted on:December 18, 2015

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
set PATH $PATH $GOPATH/bin

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

Check

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

/usr/local/opt/go/libexec/bin

and

~/golang/bin

👍