Tim Whitacre

Software Synthwave Scotch

Installing Go

Ok, so I’ve been playing around with Go for a while now and have been highly impressed. Recently, when my computer crashed and I was forced to get a new one, I was so busy that I only installed what I needed to get back up and running. This weekend, I had some free time and wanted to play with Go a little more, so I though I’d share my super simple process of getting it set up. Here we go.

First, like most tools I use on my Mac, I wanted to install Go using Homebrew. First step.

$ brew upgrade && brew update

This will make sure that Homebrew is up to date and all of your packages are as well. The upgrade command isn’t neccessary, but I usually do it before I install any new tool. Next up, let’s install it.

$ brew install go

See how easy that was. It will take a minute, but seriously that’s it for the installation. Now, we just need to do some config. Navigate to your $HOME directory, for the rest of these commands.

$ mkdir go

The above folder is where your programs will be stored and run from. You could also use golang or anything else. I prefer just go, but it’s up to you. Assuming you created a directory called go, let’s go ahead and put your Github account in there to make our lives easier later. Just replace username with your Github username.

$ mkdir -p ~/go/src/github.com/username

Now, let’s tell our computer where these files are, so we have access to the executables. Depeneing on whether you use Bash or ZSH, you will either put the folling in your .bashrc or your .zshrc.

# Configuring Go
export GOPATH=$HOME/go
export GOROOT=/usr/local/opt/go/libexec
export PATH=$PATH:$GOPATH/bin
export PATH=$PATH:$GOROOT/bin

Lastly, let’s test it all out by installing some tools to make our lives easier. First, make sure to restart your Terminal, then run the following.

$ go get golang.org/x/tools/cmd/godoc
$ go get golang.org/x/tools/cmd/vet

That’s it. Enjoy.