How To Install Go on Rocky Linux 9
In this tutorial, we will show you how to install the Go programming language on Rocky Linux 9. For those of you who didn’t know, Go, also known as Golang, is an open-source programming language that was developed by Google. It is known for its simplicity, efficiency, and scalability. Go is particularly well-suited for network programming and concurrent programming, and it is often used for building web servers, distributed systems, and other types of network-based software.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo
‘ to the commands to get root privileges. I will show you the step-by-step installation of the Go programming language on Rocky Linux. 9.
Prerequisites
- A server running one of the following operating systems: Rocky Linux 9.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- SSH access to the server (or just open Terminal if you’re on a desktop).
- An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies for Golang.
- A
non-root sudo user
or access to theroot user
. We recommend acting as anon-root sudo user
, however, as you can harm your system if you’re not careful when acting as the root.
Install Go on Rocky Linux 9
Step 1. The first step is to update your system to the latest version of the package list. To do so, run the following commands:
sudo dnf check-update sudo dnf install dnf-utils
Step 2. Installing Go Programming Language on Rocky Linux 9.
By default, Golang is not available on Rocky Linux 9 AppStream repository. Now run the following command below to download the latest version of Golang on your Rocky Linux system using wget
command:
wget https://go.dev/dl/go1.19.5.linux-amd64.tar.gz
Once it’s complete, verify the downloaded tarball version using the command below:
sha256sum go1.19.5.linux-amd64.tar.gz
Output:
36519702ae2fd573c9869461990ae550c8c0d955cd28d2827a6b159fda81ff95
Next, extract the Go tarball file:
tar -zxvf go1.19.5.linux-amd64.tar.gz -C /usr/local
Step 3. Configure Go Language.
Now is the turn to maintain the environmental variables. All this so that the installation does not have problems finding the command and the compiler:
echo 'export GOROOT=/usr/local/go' | tee -a /etc/profile echo 'export PATH=$PATH:/usr/local/go/bin' | tee -a /etc/profile
Finally, refresh your bash profile using the following command:
source /etc/profile
Verify that Go has been installed correctly by running the following command:
go version
Step 4. Create a Sample ‘hello world’ Program using Go.
Now we create a sample typical Hello World program. First, create the folders:
mkdir -p project/helloworld cd project/helloworld
Next, create the new file:
nano helloworld.go
Add the following line:
package main import "fmt" func main() { fmt.Printf("Hi, I am Meilana. Welcome to idroot.us\n") }
Save and close the file, then run the program:
go run helloworld.go
Congratulations! You have successfully installed Golang. Thanks for using this tutorial for installing the Go programming language on your Rocky Linux 9 system. For additional help or useful information, we recommend you check the official Go website.