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 |
|
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 will automatically fetch the latest binaries and install it for you, make sure they are installed to
1 |
|
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 |
|
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 |
|
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 |
|
B) If you are using zsh, open and edit:
1 |
|
and add the following:
1 2 3 4 |
|
save the file and restart the terminal or type
A) For bash:
1 |
|
B) For zsh:
1 |
|
Editing .bash_profile or .zshrc
Follow the instructions to edit .bash_profile or .zshrc, open the terminal and type
1 |
|
If you are using atom type
1 |
|
or
1 |
|
Checking the installation:¶
Checking the installation
Open the terminal and type:
1 |
|
it should give the output:
1 |
|
For windows it should give output:
1 |
|
You can also test using the following commands:
1 2 |
|