Install Go on Mac (with homebrew)

Jim Kang
Jim Kang
Jan 2 · 1 min read

Install Brew (skip if you already did)

ruby -e "$(curl -fsSL"

Update & Install Go

brew update&& brew install golang

Setup Workspace

It’s considered best practice to use $HOME/go location for your workspace, so let’s do that!

mkdir -p $HOME/go/{bin,src}

We created two important folders bin and src that’ll be used for GO

Setup Environment

We’ll need to add to .bashrc or .zshrc (if you’re using zsh) with the following info. (Ex: nano ~/.bashrc )

export GOPATH=$HOME/go
export GOROOT="$(brew --prefix golang)/libexec"
export PATH="$PATH:${GOPATH}/bin:${GOROOT}/bin"

reload the settings with source $HOME/.bashrc (or .zshrc )

Feel free to start any project (make new folder) under ~/go/src and go from there.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade