How to Install Go Language on AlmaLinux or Rocky Linux 8/9


If you’re looking for an easy way to get started with programming in a language that offers versatile features and performance, then look no further than Go! Developed by Google. Golang is designed to be simple yet powerful, making it a great fit for beginners. It also supports cross-platform development and can be used for web and mobile development including for cloud computing, machine learning, data science, and artificial intelligence.

This step-by-step guide will help you install Go on AlmaLinux or Rocky Linux so you can start coding in no time.

Install Go Language on AlmaLinux or Rocky Linux


  1. AlmaLinux or Rocky Linux
  2. Internet connection
  3. sudo or root user access

Steps to install Golang on AlmaLinux or Rocky

The commands given here will work for both Almalinux or Rocky 8 and 9.  Hence, just get to your Linux terminal and start following them.

#1st Method using Yum or DNF

1: Update AlmaLinux or Rocky Linux

If you have not updated your system for quite a while then run the system update command once before going through the guide further. This helps the DNF to rebuild the package index cache and install if any latest package update is available.

sudo dnf update

2: Use Yum or DNF to install Golang

The packages we need to install the Go programming language are available through the default repository of AlmaLinux or Rocky Linux. Hence, we can use the system’s default DNF package manager to install it. But the version of the Golang will not be the latest one. For example, while writing this tutorial the latest version was 1.20 and the one available through Yum or DNF was 1.18.

So, those who are looking for the latest version can check out the #Method-2 given in this article.

sudo dnf install golang


sudo yum install golang
Use Yum or DNF to install Golang

#2nd Method for the latest version

4. Download the Go Package

Golang offers precompiled binaries for Linux distributions like AlmaLinux, Ubuntu, RHEL, etc. To download the package.

  1. First, visit the Golang website to download Go
  2. Find the Tar file given for Linux.
  3. Click on it.
  4. A pop-up will appear to save the file.
Download the Go Package for Linux

5. Extract the Package

First switch to the Downloads directory because by default browser saves all the files in it.

cd Downloads

Create your own workspace directory anywhere convenient such as your home directory or use the ‘/usr/local’. Here we are using the latter one.

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

Now, if you want can delete the downloaded file to free space using:

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

6. Add Golang to your System Path

As we have manually downloaded and extracted the Go, our system will not know what to run when we use this programming language’s command tool. Therefore, configure the system environment for it by adding its folder usr/local/go/bin to your path.

sudo dnf install nano -y
sudo nano ~/.bashrc

Scroll to the end of the file and add the following line:

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

Save the file by pressing Ctrl+X, type Y, and then hit the Enter key.

Add Go to your System Path

7. Save and Reload Bash Configuration File

Now reload your configuration file using the source command, it will make your current session recognize the added path and let access the Go command line tool.

source ~/.bashrc

8. Check Version

To confirm the installation we have done is successful without any error, run

go version

To see all the available options we can use:

go --help
Check Golang Version

9. Write a Go program to test it

To get familiar with the programming language, let’s create a simple hello program to know how Golang works.

nano hello.go

Add the following lines

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

Save the file using Ctrl+X, Y, and hit the Enter key.

Explanation: package main – Tells the Go compiler that the file should compile as an executable program. Whereas import tell the system to import “fmt” from the Go library for printf function.

Compile the program:

go hello.go

10. Run the executable file.

After compilation, an executable file will appear in the same directory. We can execute that to see the output:


To practice further, you can use the Golang online editor or learn more from the documentation.



After following all of the above steps your system will be ready to write Go code on Almalinux or Rocky Linux. Learn further- How to create, compile & run a C Program in a Linux terminal

Related links:

1 thought on “How to Install Go Language on AlmaLinux or Rocky Linux 8/9”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.