How to Install Go on CentOS 7 / RHEL 7 server

How to Install CentOS 7 / RHEL 7 server

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

Golang is an open source programming language created by Google in 2009.

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

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

2. Install EPEL (Extra Packages for Enterprise Linux) repository on your CentOS 7 / RHEL 7 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

===================================================================================================
Package Arch Version Repository Size
===================================================================================================
Installing:
golang x86_64 1.13.6-1.el7 epel 3.2 M
Installing for dependencies:
apr x86_64 1.4.8-5.el7 base 103 k
apr-util x86_64 1.5.2-6.el7 base 92 k
cpp x86_64 4.8.5-39.el7 base 5.9 M
fipscheck x86_64 1.4.1-6.el7 base 21 k
fipscheck-lib x86_64 1.4.1-6.el7 base 11 k
gcc x86_64 4.8.5-39.el7 base 16 M
git x86_64 1.8.3.1-22.el7_8 updates 4.4 M
glibc-devel x86_64 2.17-307.el7.1 base 1.1 M
glibc-headers x86_64 2.17-307.el7.1 base 689 k
gnutls x86_64 3.3.29-9.el7_6 base 680 k
golang-bin x86_64 1.13.6-1.el7 epel 86 M
golang-src noarch 1.13.6-1.el7 epel 7.1 M
groff-base x86_64 1.22.2-8.el7 base 942 k
kernel-headers x86_64 3.10.0-1127.8.2.el7 updates 8.9 M
less x86_64 458-9.el7 base 120 k
libedit x86_64 3.0-12.20121213cvs.el7 base 92 k
libgomp x86_64 4.8.5-39.el7 base 158 k
libmodman x86_64 2.0.1-8.el7 base 28 k
libmpc x86_64 1.0.1-3.el7 base 51 k
libproxy x86_64 0.4.11-11.el7 base 64 k
mercurial x86_64 2.6.2-11.el7 base 2.6 M
mpfr x86_64 3.1.1-4.el7 base 203 k
neon x86_64 0.30.0-4.el7 base 166 k
nettle x86_64 2.7.1-8.el7 base 327 k
openssh x86_64 7.4p1-21.el7 base 510 k
openssh-clients x86_64 7.4p1-21.el7 base 655 k
pakchois x86_64 0.4-10.el7 base 14 k
perl x86_64 4:5.16.3-295.el7 base 8.0 M
perl-Carp noarch 1.26-244.el7 base 19 k
perl-Encode x86_64 2.51-7.el7 base 1.5 M
perl-Error noarch 1:0.17020-2.el7 base 32 k
perl-Exporter noarch 5.68-3.el7 base 28 k
perl-File-Path noarch 2.09-2.el7 base 26 k
perl-File-Temp noarch 0.23.01-3.el7 base 56 k
perl-Filter x86_64 1.49-3.el7 base 76 k
perl-Getopt-Long noarch 2.40-3.el7 base 56 k
perl-Git noarch 1.8.3.1-22.el7_8 updates 56 k
perl-HTTP-Tiny noarch 0.033-3.el7 base 38 k
perl-PathTools x86_64 3.40-5.el7 base 82 k
perl-Pod-Escapes noarch 1:1.04-295.el7 base 51 k
perl-Pod-Perldoc noarch 3.20-4.el7 base 87 k
perl-Pod-Simple noarch 1:3.28-4.el7 base 216 k
perl-Pod-Usage noarch 1.63-3.el7 base 27 k
perl-Scalar-List-Utils x86_64 1.27-248.el7 base 36 k
perl-Socket x86_64 2.010-5.el7 base 49 k
perl-Storable x86_64 2.45-3.el7 base 77 k
perl-TermReadKey x86_64 2.30-20.el7 base 31 k
perl-Text-ParseWords noarch 3.29-4.el7 base 14 k
perl-Time-HiRes x86_64 4:1.9725-3.el7 base 45 k
perl-Time-Local noarch 1.2300-2.el7 base 24 k
perl-constant noarch 1.27-2.el7 base 19 k
perl-libs x86_64 4:5.16.3-295.el7 base 689 k
perl-macros x86_64 4:5.16.3-295.el7 base 44 k
perl-parent noarch 1:0.225-244.el7 base 12 k
perl-podlators noarch 2.5.1-3.el7 base 112 k
perl-threads x86_64 1.87-4.el7 base 49 k
perl-threads-shared x86_64 1.43-6.el7 base 39 k
rsync x86_64 3.1.2-10.el7 base 404 k
subversion x86_64 1.7.14-14.el7 base 1.0 M
subversion-libs x86_64 1.7.14-14.el7 base 922 k
systemd-sysv x86_64 219-73.el7_8.6 updates 94 k
trousers x86_64 0.3.14-2.el7 base 289 k
Updating for dependencies:
systemd x86_64 219-73.el7_8.6 updates 5.1 M
systemd-libs x86_64 219-73.el7_8.6 updates 416 k

Transaction Summary
===================================================================================================
Install 1 Package (+62 Dependent packages)
Upgrade ( 2 Dependent packages)

Is this ok [y/d/N]: y

 
 

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

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

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

# wget https://download-ib01.fedoraproject.org/pub/epel/7/x86_64/Packages/g/golang-1.13.6-1.el7.x86_64.rpm

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

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

# yum install golang-1.13.6-1.el7.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.13.6-1.el7.x86_64.rpm

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

 
 

How to 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”

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 /]# go version
go version go1.14.3 linux/amd64