How to Install Go on CentOS 7 Linux

Go is a very new and most popular open-source programming language; Google creates it. There are many popular software/applications developed using the Go language, including Grafana, Docker, Kubernetes, and many more.

In this tutorial, we will go through the process of setting the Go language environment in your CentOS 7 Linux from download to install step-by-step.


Before starting the installation process for Go language, make sure your system runs on CentOS 7 Linux, and has user access with sudo privileges to execute administrative commands.

Installing Go on CentOS 7 Linux

The Go language installation and configuration in CentOS Linux is very easy; you can download and install Go into CentOS Linux in the few steps.

Follow the below steps to install Go on CentOS 7:

Step 1 – Downloading the Go tarball package.

Currently, the latest version of Go Language is 1.15.2 available; before downloading the tarball package, you can visit the official downloading page of Go and check available new version available.

You can download the Go binary, using either curl or wget command:

$ wget

Step 2 – Verify the Go tarball package.

You can verify the tarball checksum using the sha256sum command, as shown below:

$ sha256sum go1.15.2.linux-amd64.tar.gz

You will get the output similar like below:

68a2297eb099d1a76097905a2ce334e3155004ec08cdea85f24527be3c48e856  go1.15.2.linux-amd64.tar.gz

You should make sure the printed hash from the above command matches one from the download package mention on the download page.

Step 3 – Extract Go package.

You can use the tar command to extract the tarball package to the /usr/local directory, as shown below:

$ sudo tar -C /usr/local -xzf go1.13.linux-amd64.tar.gz

Step 4 – Configure the Path Variable

The CentOS operating system needs to manage Path for all executable programs to find the program’s executable binaries.

To configure Go executable binaries, PATH needs to adjust the $PATH environment variable. You can do this by appending the below line in the /etc/profile file:

export PATH=$PATH:/usr/local/go/bin

After adding the line, save the file and load the new PATH environment variable into the same shell session using the following command:

$ source ~/.profile

Step 5 – Verify the Go Installation

You can verify the Go programming language installation on the CentOS system by checking the version as shown below:

$ go version

You will get the output similar like below:

go version go1.15.2 linux/amd64

Go Language basics

In Go Language’s basic uses, we will set up a workspace and create a simple program, “program1,” that will print the message “hello world.”

To create a Go program, we will follow these four steps:

Step 1 – Create a Go workspace.

By default, we creating workspace directory is in the user’s home directory $HOME/go. To create it, use the following command:

$ mkdir ~/go

Step 2 – Create a program directory under the workspace.

It would be best if you created a new directory src/program1 inside the workspace, as shown below:

mkdir -p ~/go/src/program1

In the newly-created directory (program1), create a file named hello.go with the following go program:

package main
import "fmt"
func main() {
    fmt.Printf("Hello, World\n")

If you want to learn more about the Go workspace directory hierarchy, please check this link.

Step 3 – Build a Go program.

To build the go application for the program, navigate to the ~/go/src/hello directory, and make a file using the go build command, as shown below:

$ cd ~/go/src/hello
$ go build

The above command will build and an executable file named program1.

Step 4 – Run the new Go program.

You can execute the new build program by running the command, as shown below:


You will get the output similar like below:

Hello, World


Now you learn to download and install Go language in CentOS 7 Linux and learn to build workspace, write and run Go programs.

If you get any problem or having any feedback, please comment below.


Submit a Comment

Your email address will not be published. Required fields are marked *

8 + 12 =

Related Articles