Back to: Golang
Before you can start writing Golang code, you’ll need to install the Golang compiler on your system. In this article, we’ll go through the steps of installing Golang on various operating systems.
Windows:
- Download the Golang Windows installer from the official Golang website. Download Go.
- Run the installer and follow the prompts to complete the installation process.
- After installation, open a command prompt and type “go version” to verify that Golang is installed correctly.
macOS:
- Download the Golang macOS package from the official Golang website. Download Go.
- Double-click the downloaded package to start the installation process.
- After installation, open a terminal window and type “go version” to verify that Golang is installed correctly.
Linux:
- Open a terminal window and run the following command to install Golang:
sudo apt-get install golang
See “go” version by running following command:
go version
Note: The command may differ depending on your Linux distribution.
Here are the steps to install Go on CentOS:
- Open a terminal window on your CentOS machine.
- Update the package manager with the following command:
sudo yum update
- Install the EPEL repository with the following command:
sudo yum install epel-release
- Install the Go programming language using yum:
sudo yum install go
- After the installation is complete, verify the installation by checking the Go version with the following command:
go version
If everything was installed correctly, you should see the version number of the installed Go compiler.
- Set up the environment variables for Go. You’ll need to add the following lines to your
.bashrc
file:
export GOROOT=/usr/lib/golang
export PATH=$PATH:$GOROOT/bin
- After adding the lines to your
.bashrc
file, run the following command to apply the changes:
source ~/.bashrc
Alternatively, you can also download the Golang binary distribution for Linux from the official Golang website and install it manually.
After installing Golang, you can start writing Golang code and using the many powerful tools and packages available in the Golang community. Make sure to keep your Golang installation up to date with the latest versions to take advantage of new features and bug fixes.
Follow us on social media
Follow Author