Installing Multiple Version of Golang using GoEnv

Often we need a different version of go according to specific projects. There are different options we have like we can use Docker for our specific project’s need(we can talk about that in a different blog post). There are several other options but in this blog, we will talk about goenv.

Prerequisites: git

We’re using Ubuntu 20.04 so below instruction will work in ubuntu. On Mac too. Not sure about windows.

Official Installation Guide GOENV Install guide

Goto github

git clone ~/.goenv

if this particular git code syntax you(readers) are not familiar with we will explain it, it just cloning the repo and place it on .goenv folder on the home// directory.

Define environment variable GOENV_ROOT

echo 'export GOENV_ROOT="$HOME/.goenv"' >> ~/.bashrc
echo 'export PATH="$GOENV_ROOT/bin:$PATH"' >> ~/.bashrc

for zsh/oh-my-zsh users, use zshrc or respective config files according to your terminal settings.

Add goenv init to your shell

echo 'eval "$(goenv init -)"' >> ~/.bashrc

If you want goenv to manage GOPATH and GOROOT (recommended), add GOPATH and GOROOT to your shell after eval "$(goenv init -)"

echo 'export PATH="$GOROOT/bin:$PATH"' >> ~/.bashrc

echo 'export GOPATH="$HOME/<workspaces_path>/go"' >> ~/.bashrc

GOPATH Folder Structure

Restart your shell so the path changes take effect.

exec $SHELL

Install Go versions into $GOENV_ROOT/versions

goenv install <version_number>

# check all version which can be installed
goenv install -l

# Example
goenv install 1.15.6

To upgrade to a specific release of goenv

cd $(goenv root)
git pull

Uninstalling goenv

rm -rf goenv root

Disable goenv

To disable goenv managing your Go versions, simply remove the goenv init line from your shell startup configuration. This will remove goenv shims directory from PATH, and future invocations like goenv will execute the system Go version, as before goenv.

Uninstalling Go Versions

goenv uninstall

Run this command after you install a new version of Go to activate

goenv rehash

If you like you can read the same article in my personal github gist

How to use a specified version of Go (Globally or Locally)

# global
goenv global 1.15.6

# Local
goenv local 1.15.6

Yml or Yaml for DevOps

As software engineers, we are always learning new tech stacks as we process our careers. Everyone who works on any short of software farm all came across a term called DevOps. As the name suggests, ...

Working with DocuSign, Authorization and Sending Document for Signature

DocuSign is a well known platform where users can send their document for signing via email or your app. I will try to show you how DocuSign authorize an user and how can we send a document to users ...

Worker Pool in Golang

Tags: #advance #topic #golang #goroutine #channels #workerpool #threadpool Often we end up with some work which is so time-consuming that if we’re able to assign, multiple person/worker, to do ...
java web application

Top 9 Practical Benefits Of Using Java Web Application

Java web application frameworks have one of the greatest and largest communities of software engineers in the world. Companies can build a team with the help of this community at ease. There are different communities to help beginners, intermediate as well as expert developers.

Read More