Skip to content

Installing Go


How-To Install Go on your local machine

Installing on Mac OSx:

Installing on Mac OSx

Installing Go on your mac is pretty straight forward, choose any one method: -

A) Installing using package installer directly from golang.org

OR

B) Using Homebrew

A) Installing using the package installer

Package installer method is the simplest way to get you started, just download the .pkg file by clicking on this link and install it just as you would install any other program on your mac.

The installer will automatically create everything for you including setting up your environment variables.

Installer will automatically install it to

1
usr/local/go directory

After installing read "Checking the installation" section below to make sure everything works.

B) Using Homebrew

Before using this method, make sure you have homebrew installed, if it is not installed checkout this link and install it.

Open your terminal and type the following:

1
brew install go

brew will automatically fetch the latest binaries and install it for you, make sure they are installed to

1
usr/local/go directory

Its now time to setup your environment variables, check the "Setting up environment variables" to complete the installation and start using Go.

Installing on FreeBSD & Linux:

Installing on FreeBSD & Linux

Download the archive from golang.org and extract it to usr/local, for extracting open the terminal in the downloaded directory and type the following:

If you have downloaded Go v 1.10.3 type the following command, if you have downloaded some other version, change the version in the following command.

Open terminal in downloaded directory and type:

1
tar -C /usr/local -xzf go1.10.3.linux-amd64.tar.gz

After extracting set up GOPATH, refer the "Setting up environment variables" section.

Installing on Windows:

Installing on Windows

Download the msi installer from golang.org and follow the prompts to intsall it.

By default it is installed in

1
c:\Go

all the environmental variables are set automatically by the installer.

If you are using windows, I would highly recommend to install Git & Git Bash.

Setting up environment variables:

Setting up environment variables

If you have installed Go using brew on OSx or on linux you need to set up GOPATH.

A) If you are using bash, open and edit:

1
~/.bash_profile

B) If you are using zsh, open and edit:

1
~/.zshrc

and add the following:

1
2
3
4
export PATH=$PATH:/usr/local/go/bin
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export GOBIN=$HOME/go/bin

save the file and restart the terminal or type

A) For bash:

1
source ~/.bash_profile

B) For zsh:

1
source ~/.zshrc
Editing .bash_profile or .zshrc

Follow the instructions to edit .bash_profile or .zshrc, open the terminal and type

1
cd

If you are using atom type

1
atom .bash_profile

or

1
atom .zshrc

Checking the installation:

Checking the installation

Open the terminal and type:

1
echo $GOROOT

it should give the output:

1
usr/local/go

For windows it should give output:

1
c:\Go

You can also test using the following commands:

1
2
go env
go version

Buy Me A Coffee

Buy Me A Coffee