Go can be installed on most popular operating systems, you can download go binary on Windows, Linux, FreeBSD, and macOS. Each of these operating systems has it own download files, meaning you cannot use the windows download file on Linux and vice versa. Then there is the Stable versions, Unstable versions and the Archive version for each of the operating system. The stable version is the latest stable release of go and it is relatively safe to you. With the unstable version you may experience some bugs, and issues with the program, this is usually not advised for download. Lastly, we have the Archive versions that consist of the previous release of go since the stable release of version 1.0.
Installing Go on Windows
The Microsoft Windows Go binary can be downloaded from the Go Programming Language official website. The binary is compatible with Windows 7 or Later running on Intel 64 bit processor or 32-bit processor. The download version constantly changes with new releases, the binary package is usually about 100MB or more.
The windows option has two installation methods, you can use the MSI installer option or the zip archive folder download.
The MSI download is an executable file download that can be installed by clicking on the executable file to run the go binary. Once you click follow the set of instruction that follows.
The Zip Archive option has the binary file embedded inside a zip folder, unzip the folder first then run the file inside by clicking on it. Follow the instructions that follow.
Under Windows, you may set environment variables through the “Environment Variables” button on the “Advanced” tab of the “System” control panel. Some versions of Windows provide this control panel through the “Advanced System Settings” option inside the “System” control panel.
If you change the default directory during installation, you must set the GOROOT environment variable to your chosen path. See instruction on how to set your environment variable for windows below.
Restart your system to effect changes.
You can download the Windows Binary here. https://golang.org/dl/
Direct download links are not given because the version changes with new releases.
Installing Go on macOS
Installing Go on Apple macOS is quite different from other operating systems. Download the installation package from the official download site. Ensure your system is running on macOS 10.10 or higher.
Open the .pkg package that you’ve downloaded, and drag GoLand to the Applications folder or double tap to start the installation.
You may also open the go1.11.4.darwin-amd64.pkg package that you’ve downloaded, and drag GoLand to the Applications folder.
curl -o go.pkg https://dl.google.com/go/go1.11.4.darwin-amd64.pkg
shasum -a 256 go.pkg | grep
sudo open go.pkg
Once it is complete you will find that a new path has been created at /usr/local/go. You will also find a bin package added to the environment variable path. Restart your system to effect new changes.
Installing Golang on Linux
Installing Go in Linux is quite similar to installing go on macOS, download the Go binary tarball from golang.org/dl,
unzip the file to /usr/local, then add the bin path to the environment variable path. See details below.
$ wget https://dl.google.com/go/go1.11.4.linux-amd64.tar.gz
Next, check the integrity of the downloaded file as shown below.
$ sha256sum go1.11.4.linux-amd64.tar.gz
The output is dependent on the version of the go binary file.
Extract the downloaded tarball using command:
$ sudo tar -C /usr/local -xvzf go1.11.4.linux-amd64.tar.gz
This command extracts the tarball to /usr/local directory. Here, -c flag indicates the target directory.
Adjust the permissions and move the go directory to /usr/local:
sudo chown -R root:root ./go
sudo mv go /usr/local
Adjust the path variable
Using a text editor, open the ~/.profile file and add the following two lines to the bottom of the file:
Save the file, and load the commands into the current shell instance:
Test with Go version and go env.
Install go on FreeBSD
Installing go on FreeBSD is similar to running go on any UNIX based system. First, go to Golang.org/dl to download the latest stable version of Go binary for FreeBSD. Then run the following commands on your system.
tar -C /usr/local -xzf go1.11.4.freebsd-amd64.tar.gz
Then create the path to the environment variable to create the following folders.
setenv GOPATH /root/.gopkg
set path = ($path /usr/local/go/bin /root/.gopkg/bin)
And there you with go installation on FreeBSD.
Uninstalling Go and Changing Installation Path
To install a newer version of go on your system you will have to uninstall the previous version first then install the newer version.
Also installing go in a different directory or folder will require that you create three folders within the main folder.
Ensure you point the environment variable to the new path. To check if you are pointing it correctly open command prompt (CMD) and type go env it will display the details of the environment variables on the screen.