Install Golang & Setting up its path ( and Env Variable)

Mohit Rakhade
2 min readNov 13, 2020

While running the Hyperledger Fabric network on Ubuntu 20.04, I faced lots of issue while deploying chaincode due to the older version of golang-go. In this article I discribed step-by-step how to install new version of golang and set its path and env variable.

1. Clean-up everything

If you have have some older versions of Go. Then its necessary to delete that version before installing the new one. We can’t upgrade the version directly.

Run this in your terminal

To remove go-lang-packages

sudo apt-get remove golang-go

To remove all golang dependencies

sudo apt-get remove --auto-remove golang-go

Uninstall/remove ( existing ) Golang-go package

sudo rm -rvf /usr/local/go

2. Install (new) Golang-go

Download golang binary release to your machine by running this command in your terminal or you can also download this from Golang Website

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

Note : change the bold part according to the version you downloaded (or want)

Extract the archive file by running

sudo tar -xvf go1.15.5.linux-amd64.tar.gz

Move file to proper location

sudo mv go /usr/local

Now golang is installed in our system, its time to set the path so that we can use golang without entering whole path.

3. Setting up the path & env variable

From the Home directory, open .profile file by running

vim ~/.profile

added following lines to that file

export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH

Kuddos to you xD

Golang-go is now installed and path is also configured in your system. Let’s check it ones, is it properly installed or not by running —

go version

To check all Env variables

go env

Thank You for reading :)

Mohit Rakhade

--

--

Mohit Rakhade

Diving deep into Decentralized world of Blockchian to achieve transparency, enhanced security, Increased Efficiency & Improved Traceability ✨