Skip to content

Instantly share code, notes, and snippets.

@senorprogrammer
Forked from fatih/switchgo.sh
Created September 23, 2019 23:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save senorprogrammer/b7537ac310400379401b52cd8bd30cd8 to your computer and use it in GitHub Desktop.
Save senorprogrammer/b7537ac310400379401b52cd8bd30cd8 to your computer and use it in GitHub Desktop.
Switch between go version using https://github.com/golang/dl
function switchgo() {
version=$1
if [ -z $version ]; then
echo "Usage: switchgo [version]"
return
fi
if ! command -v "go$version" > /dev/null 2>&1; then
echo "version does not exist, download with: "
echo " go get golang.org/dl/${version}"
echo " go${version} download"
return
fi
go_bin_path=$(command -v "go$version")
ln -sf "$go_bin_path" "$GOBIN/go"
echo "Switched to ${go_bin_path}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment