go supports a wide range of operating systems. There are two ways
go can be installed on the system.
- Building it from the source
I am installing it on MacBook Pro with macOS Mojave v10.14.4 for this tutorial using the Mac binaries.
You could get the download link here
As shown in the image above, select the relevant package accoridng to the operating system. I have downloaded the one for
- Download file
The installation is a fairly straight. You could go with the defaults as shown below.
To verify if the
go has been successfully, it can be verified from the command line
You could use the following commands in the terminal to verfiy.
>>> which go # Returns path where go is installed/usr/local/go/bin/go>>> go version # Returns the version of the go installedgo version go1.12.4 darwin/amd64
If the terminal shows up as the above, then
go lang has been successfully installed.
Go follows a different approach to manage the code which requires to setup the project workspace. This means all the
go projects should be developed and maintained in the defined workspace.
Open the shell config which is locate in the
Add the following variables to shell config
>>> export GOPATH=$HOME/<go-workspace> # <go-workspace> is a filler. Fill it with proper path>>> export PATH=$PATH:$GOPATH/bin>>> export GOROOT=/usr/local/opt/go/libexec>>> export PATH=$PATH:$GOROOT/bin
$GOPATH/src: Go Projects source code
$GOPATH/pkg: Contains imported packages
$GOPATH/bin: The compiled binaries home
This completes the setup of
go. And system is ready for some code.