Should we setup go environment var manually? Read this
- Install golang using homebrew
brew install go
- Create go folder. I prefer to hide it using dot.
mkdir -p $HOME/.go/{bin,src,pkg}
- Set the go path by adding the following lines to file
$HOME/.zshrc
and then runsource $HOME/.zshrc
export GOPATH="$HOME/.go"
export GOROOT="$(brew --prefix go)/libexec"
export PATH="$GOPATH/bin:$PATH"
export PATH="$GOROOT/bin:$PATH"
- Check if
GOPATH
andGOROOT
pointing to the correct location by runninggo env
GOPATH="/Users/iambudi/.go"
GOROOT="/opt/homebrew/opt/go/libexec"
GOTOOLDIR="/opt/homebrew/opt/go/libexec/pkg/tool/darwin_arm64"