How to install GVM and latest Go (One-Liner)?

The gvm a.k.a. Go Version Manager is an excellent tool to maintain multiple version of Go in your system.

Instruction

If you are using zsh

Assuming that latest go at the moment is 1.14.4 and you are using zsh

zsh < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer) \
      && echo "source /home/$USERNAME/.gvm/scripts/gvm" >> ~/.zshrc && source ~/.zshrc \
      && gvm install go1.4 -B && gvm use go1.4 --default \
      && gvm install go1.14.4 && gvm use go 1.14.4 --default

If you are using bash

bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer) \
      && echo "source /home/$USERNAME/.gvm/scripts/gvm" >> ~/.bashrc && source ~/.bashrc \
      && gvm install go1.4 -B && gvm use go1.4 --default \
      && gvm install go1.14.4 && gvm use go 1.14.4 --default

The above one liner works with Ubuntu as well as Debian.

Explanation

First line (below) will install gvm.

zsh < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)

Second line will ensure loading of gvm in your shell and it will load shell configuration again for this instance

echo "source /home/$USERNAME/.gvm/scripts/gvm" >> ~/.bashrc && source ~/.bashrc

Third line will install the go version without source (-B is for Binary) which will be loaded then as default

gvm install go1.4 -B && gvm use go1.4 --default

Fourth line will install the go specified version with source and compile it using go1.4

gvm install go1.14.4 && gvm use go 1.14.4 --default

Worth Sharing?

2 Comments

    1. You should always rely on bin folder of gvm default golang. It is by default added to your path. There is no need to copy bin files to your system bin folder.

Leave a Reply to M. Stewart

Click here to cancel reply.

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>