How to Install Go on CentOS 7

Install Go on CentOS 7

In this tutorial we are going to learn how to install Go on CentOS 7. We will also install and configure its prerequisites. Go also understand as Golang, is an open source programming language developed by Google. Many popular programs, including Grafana, Docker and Kubernetes, are written in Go.

I recommend to use a minimal CentOS server setup as a basis for the tutorial, that can be a virtual or a root server image with an CentOS 7 minimal install from a web hosting company or you use our minimal server tutorial to install a server from scratch.

Install Go on CentOS 7

Step 1. First, ensure your system and apt package lists are fully up-to-date by running the following:

yum -y install epel-release
yum -y update

Step 2. Installing Go on CentOS 7.

First, download the Go binary you can use either wget or curl:


Now extract the downloaded archive and install it to the desired location on your system:

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

Then add it to your path:

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

Save the file, and load the new PATH environment variable into the current shell session:

source ~/.bash_profile

At this step, you have successfully installed and configured go language on your system. First, use the following command to check Go version:

go version

Step 3. Test the Installation.

To test whether Go is installed, we will set up a workspace and build a simple “Hello world” program:

mkdir ~/go
mkdir -p ~/go/src/hello

And in that directory create a file named hello.go:

### ~/go/src/hello/hello.go
package main

import "fmt"

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

Next, build the file switch to the ~/go/src/hello directory and run go build:

cd ~/go/src/hello
go build

Then, run the executable by simply executing the command bellow:



Hello, World

Congratulation’s! You have successfully install Go on your CentOS 7 server. Thanks for using this tutorial for installing Go language on CentOS 7 system.