The Go language, also referred to as Golang is an open-source and modern programming language created by Google.
Golang makes it possible to compile a single Go program and an executable that will run on Linux, Windows, and macOS without altering the code.
GoThe following are the steps required to install Go on CentOS 7.
Prerequisites for installation:
CentOS 7 Download and install Go tarball using the command below.
wget https://dl.google.com/go/go1.17.3.linux-amd64.tar.gz
curlcan be used in place of thewgetin the command above.
The most recent stable version of
Gois 1.17.3.
Verify the tarball checksum with the following command once the download is completed.
sha256sum go1.17.3.linux-amd64.tar.gz
The output should be similar to the one below.
550f9845451c0c94be679faf116291e7807a8d78b43149f9506c1b15eb89008c
You can compare and confirm if the hash value of the output above matches the checksum value on the Go download page based on the Go version. You can proceed with the installation if they match.
Extract the downloaded file, the tarball, to the /usr/local directory using the following command.
tar -C /usr/local -xvzf go1.17.3.linux-amd64.tar.gz
Set up the Go path environment variable to execute Go like any other command in the file system.
Add the code below to the /etc/profile file for a system-wide installation or $HOME/.bash_profile file for a current user installation.
export PATH=$PATH:/usr/local/go/bin
Save the file and load the new PATH environment variable into the present shell session. The command below saves the file into a ~/.bash_profile session.
source ~/.bash_profile
Verify the Go installation by checking the version of Go installed. Use the command below to check.
go version
You should see the following output if the installation was successful.
go version go1.17.3 linux/amd64
After a successful installation of Go, you can go ahead and create your first Go project.