Skip to content

Instantly share code, notes, and snippets.

@iambudi
Last active January 22, 2022 16:02
Show Gist options
  • Save iambudi/f079dc30e25037c21bd98dcbab613664 to your computer and use it in GitHub Desktop.
Save iambudi/f079dc30e25037c21bd98dcbab613664 to your computer and use it in GitHub Desktop.
Fresh install golang on zsh with brew on Mac M1

Should we setup go environment var manually? Read this

Installation

  1. Install golang using homebrew brew install go
  2. Create go folder. I prefer to hide it using dot. mkdir -p $HOME/.go/{bin,src,pkg}

Configure ZSH

  1. Set the go path by adding the following lines to file $HOME/.zshrc and then run source $HOME/.zshrc
export GOPATH="$HOME/.go"
export GOROOT="$(brew --prefix go)/libexec"
export PATH="$GOPATH/bin:$PATH"
export PATH="$GOROOT/bin:$PATH"
  1. Check if GOPATH and GOROOT pointing to the correct location by running go env
GOPATH="/Users/iambudi/.go"
GOROOT="/opt/homebrew/opt/go/libexec"
GOTOOLDIR="/opt/homebrew/opt/go/libexec/pkg/tool/darwin_arm64"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment