Skip to content

Instantly share code, notes, and snippets.

@lggomez
Last active December 2, 2022 19:51
Show Gist options
  • Select an option

  • Save lggomez/ba8ac4ac4100f6affd3903819c00118f to your computer and use it in GitHub Desktop.

Select an option

Save lggomez/ba8ac4ac4100f6affd3903819c00118f to your computer and use it in GitHub Desktop.
Easy setup to switch between go versions (1.11+) with gvm - go version manager
#!/usr/bin/env bash
echo $BASH_VERSION
# GVM readme: https://github.com/e-nikolov/gvm/blob/master/README.md
bash < <(curl -s -S -L https://raw.githubusercontent.com/e-nikolov/gvm/master/binscripts/gvm-installer)
source $HOME/.gvm/scripts/gvm
# To view available versions to install run 'gvm listall' later on
# Older versions you'll probably not need
gvm install go1.11.13 --prefer-binary
gvm install go1.12.13 --prefer-binary
gvm install go1.13.10 --prefer-binary
gvm install go1.14.1 --prefer-binary
echo '' >>~/.bash_profile
echo '# GO version manager' >>~/.bash_profile
echo '[[ -s "$HOME/.gvm/scripts/gvm" ]] && source "$HOME/.gvm/scripts/gvm"' >>~/.bash_profile
#select latest as default upon session init
echo 'gvm use go1.14.1 --default' >>~/.bash_profile
#select latest default after completion
gvm use 1.14.1 --default
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment