Install Go on Mac (with homebrew)

Jim Kang
1 min readJan 2, 2020

Install Brew (skip if you already did)

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Add HomeBrew to PATH (skip if you already did, I am using zsh)

(echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"

Update & Install Go

brew update&& brew install golang

Test Installed Go

go version

That’s it!

(As of GO 1.11, you don’t need to setup workspace anymore)

(Obsolete) 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,pkg}

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

(Obsolete) 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"

--

--

Jim Kang
Jim Kang

Written by Jim Kang

love writing bit sized programming memo, acoustic guitarist, proud daddy of 5 and great listener (to my kids)