Mac OS install and setup
Install on Mac OS
Using official binaries
.pkg installer from https://golang.org/dl/ and run it.
- if you don’t have Homebrew installed, install it following the instructions
brew install go
Setup on Mac OS
After installing the compiler you need to configure
GOPATH environment variable.
Since Go 1.8, the
GOPATH environment variable has the default value of
$HOME/go, so you can skip setting it.
Create the go directory with
Add the following to your
export GOPATH=$HOME/go export PATH=$PATH:$GOPATH/bin
Load the changes with
source ~/.bash_profile or launch a new terminal for the changes to take effect.
~/.bash_profile is executed at startup by the default
By adding commands there we make them available inside every shell session.
PATH is a matter of convenience. When you install Go programs with
go get ..., you will be able to invoke them without typing the full path. For example, you would run
gotest1 rather than
To quickly cd to a directory with Go source code I add bash alias to
alias cdgo="cd $GOPATH/src/github.com/kjk"
You need to change
github.com/kjk for your GitHub account.
You should understand the effect of GOPATH.