How to Install Go 1.6 on CentOS 7
In 2007, Google created a language called Go, an ALGOL-like language. It’s compiled and statically typed, and like most modern languages has garbage collection and is memory safe. In 2009 Google released this open source language to the general public, licensing it under the BSD.
For the purpose of keeping this guide short, we’ll perform all commands with the root user. In a production environment, make sure to run your scripts and application inside an user instead.
Note that the official repository for CentOS 7 only includes Go 1.4.2. Install from source to get the latest version.
Before we start, make sure your system is fully updated with the latest packages by running this command:
yum -y update
Installing the Go 1.6 files on your server
Here we will provide two different ways to install the Go programming language on your server. First we will show you how to install it via a package repository and then we will show you how to install it from source.
Installing from a repository is the quickest and easiest method. It also provides you the most stable version to date. Installing from source will get you the latest version, but it may be more difficult. Therefore, choose the more appropriate method for your needs.
Note: The official repository for CentOS 7 only includes Go 1.4.2. This is just fine for most purposes, but if you need the bleeding-edge version of Go, then install it from source.
Installing Go from package repositories
Go is located in the official repositories. Install the Go package and its dependencies.
yum install golang
Verify the version number.
root@go-node:~# go version
go version go1.4.2 linux/amd64
Installing Go 1.6 from source
First, navigate to the root folder and download the Go source.
Extract the source and afterwards adjust its permissions.
tar -zxvf go1.6.linux-amd64.tar.gz
chown -R root:root go
Now, move the go directory to /usr/local.
mv go /usr/local
Create a directory to deploy your Go-built applications.
In order to run Go 1.6, you must properly configure its paths. Add these two lines at the bottom of the file:
Activate the changes by this method.
Finally, test your Go installation.
Verify the version number like so:
go version go1.6 linux/amd64
Whether you installed from the repository or from source, you should now have a successful installation of Go to experiment with. If this guide was helpful to you, kindly share it with others who may also be interested.