(Last Updated On: January 26, 2019)

Are you looking for an easy way to install Go on RHEL 8?. Go or Golang is an open source programming language designed to ease the Development of reliable, simple, and efficient applications.

RHEL 8 doesn’t come with Go pre-installed but you’ll have to download and install the package from RHEL 8 upstream repositories. The process is simple enough that it doesn’t require good understanding of Linux and Red Hat system.

Linux Mint 19: How to Install Go (Golang) on Linux Mint 19

For Ubuntu 18.04/ CentOS 7, refer to: How to Install latest Go on CentOS 7 / Ubuntu 18.04

How to Install Go on RHEL 8

You can confirm the availability of Go on RHEL 8 by running the command below.

sudo yum module list go-toolset

The package has the name “go-toolset“. Install Go on RHEL 8 using:

sudo yum module -y install go-toolset

Confirm the RPM package details:

$ rpm -qi go-toolset
Name : go-toolset
Version : 1.10.3
Release : 10.module+el8+2175+e66141eb
Architecture: x86_64
Install Date: Wed 16 Jan 2019 11:27:49 PM EAT
Group : Unspecified
Size : 0
License : GPLv2+
Signature : RSA/SHA256, Tue 06 Nov 2018 12:09:01 AM EAT, Key ID 938a80caf21541eb
Source RPM : go-toolset-1.10.3-10.module+el8+2175+e66141eb.src.rpm
Build Date : Mon 05 Nov 2018 09:24:07 PM EAT
Build Host : x86-vm-07.build.eng.bos.redhat.com
Relocations : (not relocatable)
Packager : Red Hat, Inc. http://bugzilla.redhat.com/bugzilla
Vendor : Red Hat, Inc.
Summary : Package that installs go-toolset
Description :
This is the main package for go-toolset.

Test Go installation on RHEL 8

Now that we have Go installed on RHEL 8, let’s test to ensure it is working.

Start by creating your workspace directory.

mkdir $HOME/go

Create a directory inside it to host a test Go application.

cd $HOME/go
mkdir -p src/helloworld

Create a file named helloworld.go that looks like:

package main
import "fmt"
func main() {
	fmt.Printf("hello, world\n")
}

Build the application with go tool

cd $HOME/go/src/helloworld
go build

This will generate a new file called helloworld .

$ ls
helloworld helloworld.go

Execute the file by running.

$ ./helloworld 
hello, world

To install the binary into your workspace’s bin directory, use:

$ go install
$ ls ~/go/bin/
helloworld

To remove it use:

go clean -i

You can add your Go binary directory to $PATH.

$ vim ~/.bashrc 
export PATH="$PATH:~/go/bin/"

You have installed Go on RHEL 8. Enjoy developing Go applications on your RHEL workstation.