How to Install Go Lang on Rocky Linux 9.2

To Install Go Lang On Rocky Linux 9.2

Introduction:

The Go language was developed by Google as an open-source programming language. There are a variety of operating systems and frameworks used by software developers to create web applications, cloud services, and networking applications.

Installation Procedure:

Step 1: Check the version of OS by using the below command

[root@Linuxhelp ~]# cat /etc/os-release
NAME="Rocky Linux"
VERSION="9.2 (Blue Onyx)"
ID="rocky"
ID_LIKE="rhel centos fedora"
VERSION_ID="9.2"
PLATFORM_ID="platform:el9"
PRETTY_NAME="Rocky Linux 9.2 (Blue Onyx)"
ANSI_COLOR="0;32"
LOGO="fedora-logo-icon"
CPE_NAME="cpe:/o:rocky:rocky:9::baseos"
HOME_URL="https://rockylinux.org/"
BUG_REPORT_URL="https://bugs.rockylinux.org/"
SUPPORT_END="2032-05-31"
ROCKY_SUPPORT_PRODUCT="Rocky-Linux-9"
ROCKY_SUPPORT_PRODUCT_VERSION="9.2"
REDHAT_SUPPORT_PRODUCT="Rocky Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="9.2"

Step 2: Update the System by using the below command

[root@Linuxhelp ~]# dnf update
Last metadata expiration check: 1:12:12 ago on Sun 09 Jul 2023 06:46:27 AM IST.
Dependencies resolved.
==============================================================================================================
 Package                          Architecture      Version                        Repository            Size
==============================================================================================================
Upgrading:
 open-vm-tools                    x86_64            12.1.5-1.el9_2.1               appstream            851 k
 open-vm-tools-desktop            x86_64            12.1.5-1.el9_2.1               appstream            158 k




Transaction Summary
==============================================================================================================
Upgrade  2 Packages

Total download size: 1.0 M
Is this ok [y/N]: y
Downloading Packages:
(1/2): open-vm-tools-desktop-12.1.5-1.el9_2.1.x86_64.rpm                      618 kB/s | 158 kB     00:00    
(2/2): open-vm-tools-12.1.5-1.el9_2.1.x86_64.rpm                              2.5 MB/s | 851 kB     00:00    
--------------------------------------------------------------------------------------------------------------
Total                                                                         910 kB/s | 1.0 MB     00:01     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                      1/1 
  Upgrading        : open-vm-tools-12.1.5-1.el9_2.1.x86_64                                                1/4 
  Running scriptlet: open-vm-tools-12.1.5-1.el9_2.1.x86_64                                                1/4 
  Upgrading        : open-vm-tools-desktop-12.1.5-1.el9_2.1.x86_64                                        2/4 
  Running scriptlet: open-vm-tools-desktop-12.1.5-1.el9_2.1.x86_64                                        2/4 
  Running scriptlet: open-vm-tools-desktop-12.1.5-1.el9.x86_64                                            3/4 
  Cleanup          : open-vm-tools-desktop-12.1.5-1.el9.x86_64                                            3/4 
  Running scriptlet: open-vm-tools-desktop-12.1.5-1.el9.x86_64                                            3/4 
  Running scriptlet: open-vm-tools-12.1.5-1.el9.x86_64                                                    4/4 
  Cleanup          : open-vm-tools-12.1.5-1.el9.x86_64                                                    4/4 
 
 Running scriptlet: open-vm-tools-12.1.5-1.el9.x86_64                                                    4/4 
  Verifying        : open-vm-tools-desktop-12.1.5-1.el9_2.1.x86_64                                        1/4 
  Verifying        : open-vm-tools-desktop-12.1.5-1.el9.x86_64                                            2/4 
  Verifying        : open-vm-tools-12.1.5-1.el9_2.1.x86_64                                                3/4 
  Verifying        : open-vm-tools-12.1.5-1.el9.x86_64                                                    4/4 

Upgraded:
  open-vm-tools-12.1.5-1.el9_2.1.x86_64             open-vm-tools-desktop-12.1.5-1.el9_2.1.x86_64            

Complete!

Step 3: Download Go Lang from the official website by using wget Command

 [root@Linuxhelp ~]# wget https://golang.org/dl/go1.16.5.linux-amd64.tar.gz
--2023-07-09 07:58:59--  https://golang.org/dl/go1.16.5.linux-amd64.tar.gz
Resolving golang.org (golang.org)... 142.250.77.177, 2404:6800:4007:818::2011
Connecting to golang.org (golang.org)|142.250.77.177|:443... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://go.dev/dl/go1.16.5.linux-amd64.tar.gz [following]
--2023-07-09 07:59:00--  https://go.dev/dl/go1.16.5.linux-amd64.tar.gz
Resolving go.dev (go.dev)... 216.239.34.21, 216.239.36.21, 216.239.32.21, ...
Connecting to go.dev (go.dev)|216.239.34.21|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://dl.google.com/go/go1.16.5.linux-amd64.tar.gz [following]
--2023-07-09 07:59:00--  https://dl.google.com/go/go1.16.5.linux-amd64.tar.gz
Resolving dl.google.com (dl.google.com)... 172.217.166.110, 2404:6800:4007:811::200e
Connecting to dl.google.com (dl.google.com)|172.217.166.110|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 129049763 (123M) [application/x-gzip]
Saving to: ‘go1.16.5.linux-amd64.tar.gz’



go1.16.5.linux-amd64.tar.gz 100%[=========================================>] 123.07M  9.64MB/s    in 13s     

2023-07-09 07:59:13 (9.55 MB/s) - ‘go1.16.5.linux-amd64.tar.gz’ saved [129049763/129049763]

Step 4: Extract the archive by using the below command

 [root@Linuxhelp ~]#  tar -C /usr/local -xzf go1.16.5.linux-amd64.tar.gz

Step 5: Set the Go environment variables and Add the following lines at the end of the file open /etc/profile file using a vim text editor.

 [root@Linuxhelp ~]# vim /etc/profile
export PATH=$PATH:/usr/local/go/bin
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin

Then save & Exit from the file.

Step 6: Load the updated environment variables by using the below command or you can restart your system

 [root@Linuxhelp ~]# source /etc/profile

Step 7: Now check the Go Lang version by using the below Command

 [root@Linuxhelp ~]# go version
go version go1.16.5 linux/amd64

Conclusion:

We have reached the end of this article. In this guide, we have walked you through the steps required to Install Go Lang on Rocky Linux 9.2. Your feedback is much welcome.

FAQ
Q
How will you check the version of go?
A
To check the version using the command (go version).
Q
How will you add the go function file and run it?
A
To add and run the go function file, use the source /root/.zshrc command
Q
Which command line was used to install the package?
A
The command line used to install the package is ./installer_linux
Q
2) Which permission do we need to give?
A
Executable Permission (chmod +x installer_linux)
Q
How will you download the go installation package?
A
To download the go installation package use wget -q https://storage.googleapis.com/golang/getgo/installer_linux