How to Install Go on CentOS 8
Updated on
•6 min read

Go, often referred to as golang is a modern open-source programming language created by Google that allows you to build reliable and efficient applications.
Many popular applications, such as Kubernetes, Docker, Prometheus, and Terraform, are written in Go.
This tutorial explains how to download and install Go on CentOS 8.
Downloading and Installing Go on CentOS 8
At the time of writing this article, the latest stable version of Go is version 1.13.4. Before downloading the tarball, visit the official Go downloads page and check if there is a new version available.
Perform the following steps below to download and install Go on CentOS 8:
Download the Go binary using either the
wgetorcurlutility:wget https://dl.google.com/go/go1.13.4.linux-amd64.tar.gzOnce the archive is downloaded, verify the tarball checksum by typing:
sha256sum go1.13.4.linux-amd64.tar.gzMake sure the hash printed from the
sha256sumcommand matches the one from the downloads page.692d17071736f74be04a72a06dab9cac1cd759377bd85316e52b2227604c004c go1.13.4.linux-amd64.tar.gzExtract the tarball to the
/usr/localdirectory using thetarcommand:sudo tar -C /usr/local -xf go1.13.4.linux-amd64.tar.gzThe command above must be run as root or a user with sudo privileges .
Tell the system where to find the Go executable binaries by adjusting the
$PATHenvironment variable.You can do this by adding the following line to the
/etc/profilefile (for a system-wide installation) or to the$HOME/.bash_profilefile (for a current user installation):~/.bash_profileexport PATH=$PATH:/usr/local/go/binSave the file, and load the new
PATHenvironment variable into the current shell session using thesourcecommand:source ~/.bash_profile
That’s it. At this point, Go has been installed on your CentOS system.
Test the Installation
To test whether Go is installed correctly, we will set up a workspace and build a simple “Hello world” program.
The location of the workspace directory is specified with the
GOPATHenvironment variable. By default, it is set to$HOME/go. To create the directory run the following command:mkdir ~/goInside the workspace create a new directory
src/hello:mkdir -p ~/go/src/helloIn that directory create a file named
hello.go:nano ~/go/src/hello/hello.goPaste the following code to the file:
~/go/src/hello/hello.gopackage main import "fmt" func main() { fmt.Printf("Hello, World\n") }Navigate to the
~/go/src/hellodirectory and rungo buildto build the code:cd ~/go/src/hellogo buildThe command above will build an executable named
hello.Run the executable by typing:
./helloIf you see the following output, then you have successfully installed Go.
Hello, World
Conclusion
Now that you have downloaded and installed Go, you can start writing your Go code .
If you hit a problem or have feedback, leave a comment below.


