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
Download the Go binary using wget:
wget https://dl.google.com/go/go1.13.5.linux-amd64.tar.gzThen verify the tarball checksum by typing:
sha256sum go1.13.5.linux-amd64.tar.gzThe output should look like this:
cde4af177ef9f218f51f5e12041f43004f9fa1b0e45d3b647c252aba04901035 go1.13.5.linux-amd64.tar.gzExtract the tarball using tar to /usr/local directory:
sudo tar -C /usr/local -xf go1.13.5.linux-amd64.tar.gz2. Set Go Path
Open /.bash_profile file:
sudo nano ~/.bash_profileAdd 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_profileTo verify go installation, run this command:
go versionYou’ll see the output like this:
go version go1.13.5 linux/amd643. Run Hello World Program
Create the Go workspace:
mkdir $HOME/golangInside the workspace make directory src/hello:
mkdir -p $HOME/golang/src/helloCreate hello.go file inside hello folder:
sudo nano ~/golang/src/hello/hello.goNow 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 buildRun the executable by typing:
./helloThe output should be:
Hello, WorldMd Obydullah
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.
