Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

golang
programming
go
centos
communitycreator

How to install Golang on CentOS 7

Wale Moshood

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.

Steps to install Go

The following are the steps required to install Go on CentOS 7.

Step 1

Prerequisites for installation:

  • An enabled CentOS 7 VPSvirtual private server with root access or a user with Sudo privileges.

Download and install Go tarball using the command below.


wget https://dl.google.com/go/go1.17.3.linux-amd64.tar.gz

curl can be used in place of the wget in the command above.

The most recent stable version of Go is 1.17.3.

Step 2

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.

Step 3

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

Step 4

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

Step 5

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

Step 6

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.

RELATED TAGS

golang
programming
go
centos
communitycreator
RELATED COURSES

View all Courses

Keep Exploring