Install Go Language on AlmaLinux 8 with 2 Easy Methods

In this guide, we want to teach you to Install Go Language on AlmaLinux 8. Go, also known as Golang, is an open-source, compiled, and statically typed programming language designed by Google. It is built to be simple, high-performing, readable, and efficient.

Go is one of the simplest programming languages out there. It is easy to pick up, especially if you already know any other programming language. You can now proceed to the following steps on the Orcacore website to finish the Golang programming language setup on ALmaLinux 8.

Steps To Install Go Language on AlmaLinux 8

To complete the Golang programming language setup on ALmaLinux 8, you must log in to your server as a non-root user with sudo privileges. To do this, you can follow our guide on Initial Server Setup with AlmaLinux 8.

You can install Golang from both the Dnf package manager and from the source. Let’s see how to do it.

Method 1. Install Golang Programming Language with DNF

Go language packages are available in the default AlmaLinux repository. You can easily use the DNF package manager to install it.

First, update your local package index with the command below:

sudo dnf update -y

Then, use the following command to install Golang on AlmaLinux 8:

sudo dnf install golang -y

This method is not in the latest version. You can proceed to the next step to install the latest version of Golang on your AlmaLinux server.

Method 2. Install Golang Programming Language From Source

At this point, you can follow the steps below t install the latest version of Go language.

Download Go From Source

Here you can visit the Go Downloads page and use the wget command to download the Tar file given for Linux:

sudo wget https://go.dev/dl/go1.20.1.linux-amd64.tar.gz

Then, extract your downloaded file in the /usr/local directory by using the command below:

sudo tar -xzf go*.linux-amd64.tar.gz -C /usr/local

Note: If you don’t have the tar package installed on your server, you can use the command below to install it:

sudo dnf install tar -y

When your extraction is completed, you can delete your downloaded file to free your space:

sudo rm go*.linux-amd64.tar.gz

Configure System Environment Path

At this point, you need to configure the system environment for Go by adding its folder usr/local/go/bin to your path.

Open the bashrc file by using your favorite text editor, here we use vi editor:

sudo vi ~/.bashrc

Add the following line at the end of the file:

export PATH=$PATH:/usr/local/go/bin

When you are done, save and close the file.

Next, reload your configuration file by using the following command:

source ~/.bashrc

Verify your Go installation on AlmaLinux 8 by checking its version:

go version
Output
go version go1.20.1 linux/amd64

To get options and the help of Go, you can run the command below:

go --help
Golang Programming Language

Test Go Language

At this point, you can create a test program with Go language to see if it is working correctly.

Create a sample hello world file by using your favorite text editor, here we use vi editor:

vi hello.go

Add the following content to the file:

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

When you are done, save and close the file.

Compile the program by using the following command:

go build hello.go

Then, run your executable file:

./hello
Output
hello world

That’s it, you are done.

Conclusion

At this point, you have learned to Install Go Language or Golang on AlmaLinux 8. And you have learned to create a test program to see if your Go language is working correctly.

Hope you enjoy it. You may also like these articles:

Install and Configure OpenNMS on AlmaLinux 8

Install FreeRADIUS and daloRADIUS on AlmaLinux 8

Nginx Web Server Setup AlmaLinux 8

Securing Nginx with Let’s Encrypt on AlmaLinux 8

Redis Configuration AlmaLinux 8

Config Bind on AlmaLinux 8

Share your love

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!