Reference: 1
install golang with brew:
$ brew update
$ brew install golang
setting up PATH environment variable (in ~/.bash_profile):
export GOPATH=(the path of golang directory for source and binary)
export GOBIN=$GOPATH/bin
export GOROOT=/usr/local/opt/go/libexec
export PATH=$PATH:$GOPATH/bin
export PATH=$PATH:$GOROOT/bin