Install Latest Go on CentOS 8 / RHEL 8

In this article, we are going to install Go on CentOS / RHEL 8. At the time of writing the article, the Go is version 1.13.5. Check their official page to download the latest version.

Table of Contents

  1. Download Go
  2. Set Go Path
  3. Run Hello World Program

1. Download Go

Download the Go binary using wget:


Then verify the tarball checksum by typing:

sha256sum go1.13.5.linux-amd64.tar.gz

The output should look like this:

cde4af177ef9f218f51f5e12041f43004f9fa1b0e45d3b647c252aba04901035 go1.13.5.linux-amd64.tar.gz

Extract the tarball using tar to /usr/local directory:

sudo tar -C /usr/local -xf go1.13.5.linux-amd64.tar.gz

2. Set Go Path

Open /.bash_profile file:

sudo nano ~/.bash_profile

Add the following lines:

export GOPATH=$HOME/golang
export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin

Save the file and reload PATH using this command:

source ~/.bash_profile

To verify go installation, run this command:

go version

You’ll see the output like this:

go version go1.13.5 linux/amd64

3. Run Hello World Program

Create the Go workspace:

mkdir $HOME/golang

Inside the workspace make directory src/hello:

mkdir -p $HOME/golang/src/hello

Create hello.go file inside hello folder:

sudo nano ~/golang/src/hello/hello.go

Now paste the following code:

package main

import "fmt"

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

Build the program:

# navigate to hello folder
cd ~/golang/src/hello
# build
go build

Run the executable by typing:


The output should be:

Hello, World

Software Engineer | Ethical Hacker & Cybersecurity...

Md Obydullah is a software engineer and full stack developer specialist at Laravel, Django, Vue.js, Node.js, Android, Linux Server, and Ethichal Hacking.