The first step towards mastering the Go language is to install the Go compiler in your system. Go compiler can be installed on different types of systems like Windows, Linux, and Mac, etc. You can download the Go software for the corresponding platform from https://golang.org/dl/.
Go installation in Windows
Installing Go in the Windows system is very straightforward. Below are the steps:
- Download the
.msifile from https://golang.org/dl/.
- Double click to start the installation and follow the prompts.
- By default, this will install into the folder
C:\Program Files\Go\; you can change the path as you wish. You need to set the Go root environment variable to your chosen path. I am installing in the path
- Next, add the bin subdirectory of your Go root (for example,
C:\Go\bin) to your PATH environment variable.
Go installation in Mac
- Download the required
.pkgfile from https://golang.org/dl/.
- Double click on the downloaded file to start the installation. Follow the prompts to complete the installation process.
- This will install the package into
usr/local/godirectory by default.
- Go root path in this case will be
/usr/local/go/bin. Go automatically add the GO path to the environment variable.
Go installation in Linux
- Download the zip file (.gz) file from the download page i.e. https://golang.org/dl/.
- And unzip and untar the file to
- Now, add
/usr/local/go/binto the PATH environment variable. You can use the following command.
Verify the Go installation
To check if the Go has been installed successfully, type the command
go version in the terminal and it will show the installed Go version. Here is the output in my terminal.
go version go1.16.5 windows/amd64
go1.16.5 was the Go version when I installed and writing this tutorial. This indicates that Go has been successfully installed.
In the next tutorial, we will write our first program and execute it.