How to Install go on CentOS 8 / RHEL 8 server

How to Install go on CentOS 8 / RHEL 8 server

Follow the below steps to install Go on CentOS 8 / RHEL 8 server.

Golang is an open source programming language created by Google.

Applications like Docker, InfluxDB, OpenShift, Terraform, Kubernetes etc are written in Go programming language.

1. To Install Go you must log into your Linux server as root or as sudo user

2. Install EPEL (Extra Packages for Enterprise Linux) repository on your CentOS 8 / RHEL 8 server

Command to install EPEL repo :
 

# yum install epel-release

 
You will see the error ‘No package golang available’, if EPEL repo is not installed on your server.
 

 

3. Enter ‘y’ and press enter, if yum ask for confirmation while installing.

4. You can install Go using yum command.

Command to install Golang :
 

#yum install golang

 
Yum will install Golang package and the below dependencies.
 

[root@server /]# yum install golang

Extra Packages for Enterprise Linux Modular 8 - x86_64 4.7 kB/s | 118 kB 00:25
Extra Packages for Enterprise Linux 8 - x86_64 233 kB/s | 6.8 MB 00:29
Dependencies resolved.
===================================================================================================
Package Arch Version Repository Size
===================================================================================================
Installing:
golang x86_64 1.12.12-4.module_el8.1.0+271+e71148fc AppStream 643 k
Upgrading:
glibc x86_64 2.28-72.el8_1.1 BaseOS 3.7 M
glibc-common x86_64 2.28-72.el8_1.1 BaseOS 836 k
glibc-minimal-langpack x86_64 2.28-72.el8_1.1 BaseOS 48 k
openssl-libs x86_64 1:1.1.1c-2.el8_1.1 BaseOS 1.5 M
Installing dependencies:
cpp x86_64 8.3.1-4.5.el8 AppStream 10 M
gcc x86_64 8.3.1-4.5.el8 AppStream 23 M
golang-bin x86_64 1.12.12-4.module_el8.1.0+271+e71148fc AppStream 127 M
golang-src noarch 1.12.12-4.module_el8.1.0+271+e71148fc AppStream 6.8 M
isl x86_64 0.16.1-6.el8 AppStream 841 k
libmpc x86_64 1.0.2-9.el8 AppStream 59 k
glibc-devel x86_64 2.28-72.el8_1.1 BaseOS 1.0 M
glibc-headers x86_64 2.28-72.el8_1.1 BaseOS 469 k
kernel-headers x86_64 4.18.0-147.8.1.el8_1 BaseOS 2.7 M
keyutils-libs-devel x86_64 1.5.10-6.el8 BaseOS 48 k
krb5-devel x86_64 1.17-9.el8 BaseOS 548 k
libcom_err-devel x86_64 1.44.6-3.el8 BaseOS 38 k
libgomp x86_64 8.3.1-4.5.el8 BaseOS 203 k
libkadm5 x86_64 1.17-9.el8 BaseOS 184 k
libpkgconf x86_64 1.4.2-1.el8 BaseOS 35 k
libselinux-devel x86_64 2.9-2.1.el8 BaseOS 199 k
libsepol-devel x86_64 2.9-1.el8 BaseOS 86 k
libverto-devel x86_64 0.3.0-5.el8 BaseOS 18 k
libxcrypt-devel x86_64 4.1.1-4.el8 BaseOS 25 k
openssl x86_64 1:1.1.1c-2.el8_1.1 BaseOS 686 k
openssl-devel x86_64 1:1.1.1c-2.el8_1.1 BaseOS 2.3 M
pcre2-devel x86_64 10.32-1.el8 BaseOS 605 k
pcre2-utf16 x86_64 10.32-1.el8 BaseOS 228 k
pcre2-utf32 x86_64 10.32-1.el8 BaseOS 220 k
pkgconf x86_64 1.4.2-1.el8 BaseOS 38 k
pkgconf-m4 noarch 1.4.2-1.el8 BaseOS 17 k
pkgconf-pkg-config x86_64 1.4.2-1.el8 BaseOS 15 k
zlib-devel x86_64 1.2.11-10.el8 BaseOS 56 k
Installing weak dependencies:
glibc-langpack-en x86_64 2.28-72.el8_1.1 BaseOS 818 k
openssl-pkcs11 x86_64 0.4.8-2.el8 BaseOS 64 k
Enabling module streams:
go-toolset rhel8

Transaction Summary
===================================================================================================
Install 31 Packages
Upgrade 4 Packages

Total download size: 185 M
Is this ok [y/N]: y

 
 

How to download and install Golang rpm on CentOS 8 / RHEL 8 server

1. Log into your CentOS 8 / RHEL 8 server as root user or sudo user

2. You can download Go from centos.org website using wget command
 

# wget http://mirror.centos.org/centos/8/AppStream/x86_64/os/Packages/golang-1.12.12-4.module_el8.1.0+271+e71148fc.x86_64.rpm

 
3. Install the downloaded rpm file using either yum or rpm command

(a) Install using yum command on CentOS / RHEL x86_64 server :
 

# yum install golang-1.12.12-4.module_el8.1.0+271+e71148fc.x86_64.rpm

 
yum will install golang and the required dependencies

(b) Install using rpm command on CentOS / RHEL x86_64 server :
 

# rpm -ivh golang-1.12.12-4.module_el8.1.0+271+e71148fc.x86_64.rpm

 
You must first install the dependencies If you are installing using rpm
command
 

 
 

How to download and Install Golang Binary

1. Log into your Linux server as ‘root’ user

2. Download latest stable version of Golang from golang.org website

URL to download Golang : https://golang.org/dl/

3. Paste the below URL in browser or use wget command to download go in tar.gz format
 

https://golang.org/doc/install?download=go1.14.3.linux-amd64.tar.gz

OR

# wget https://dl.google.com/go/go1.14.3.linux-amd64.tar.gz

 
New version might be available. Always check the latest version of go in golang.org website before downloading.

4. Download the tar.gz archive and extract it into /usr/local Directory
 

# tar -C /usr/local -xzf go1.14.3.linux-amd64.tar.gz

 
5. Add /usr/local/go/bin to the PATH environment variable

Run “export PATH=$PATH:/usr/local/go/bin”
 

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

 
Add the above line to your /etc/profile file.
 

# vi /etc/profile
export PATH=$PATH:/usr/local/go/bin

 
Run the below command to check the version of go.
 

[root@server src]# go version
go version go1.12.12 linux/amd64