We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Learn how to – How To Install Go on CentOS 8 / RHEL 8

Learn how to – How To Install Go on CentOS 8 / RHEL 8.

Are you looking for an easy way to install Go (Golang) on CentOS 8 / 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: How to Install Go (Golang) on Linux Mint

For Ubuntu refer to: How to Install latest Go on Ubuntu

Option 1) Install Go on CentOS 8 / RHEL 8 from AppStream repo

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.18.4
Release     : 1.module+el8.7.0+1073+99e3b3cd
Architecture: x86_64
Install Date: Thu 19 Jan 2023 05:09:36 PM UTC
Group       : Unspecified
Size        : 0
License     : BSD and Public Domain
Signature   : RSA/SHA256, Tue 08 Nov 2022 07:10:44 PM UTC, Key ID 15af5dac6d745a60
Source RPM  : go-toolset-1.18.4-1.module+el8.7.0+1073+99e3b3cd.src.rpm
Build Date  : Tue 08 Nov 2022 06:14:48 PM UTC
Build Host  : ord1-prod-x86build003.svc.aws.rockylinux.org
Relocations : (not relocatable)
Packager    : infrastructure@rockylinux.org
Vendor      : Rocky
Summary     : Package that installs go-toolset
Description :
This is the main package for go-toolset.

Option 2) Install Go on CentOS 8 / RHEL 8 using installer_linux

Remove Go installed using module

sudo yum module -y remove go-toolset

Download installer with wget to your local system.

wget https://storage.googleapis.com/golang/getgo/installer_linux

After downloading the file, make it executable:

chmod +x ./installer_linux

And lastly run the installer from your current terminal shell.

$ ./installer_linux 
Welcome to the Go installer!
Downloading Go version go1.19.5 to /root/.go
This may take a bit of time...
Downloaded!
Setting up GOPATH
GOPATH has been set up!

One more thing! Run `source /root/.bash_profile` to persist the
new environment variables to your current session, or open a
new shell prompt.

Source the ~/.bash_profile to start using Go environment variables in your current session.

$ source ~/.bash_profile
$ go version
go version go1.19.5 linux/amd64

Test Go installation on CentOS 8 / 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
cd src/helloworld

Create a file named helloworld.go that looks like:

tee helloworld.go<<EOF
package main
import "fmt"
func main() {
	fmt.Printf("hello, worldn")
}
EOF

Build the application with go tool

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 / CentOS 8. Enjoy developing Go applications on your RHEL workstation.

Cart

Your Cart is Empty

Back To Shop