Skip to content

Instantly share code, notes, and snippets.

@codeactual
Forked from fatih/switchgo.sh
Created September 24, 2019 12:20
Show Gist options
  • Select an option

  • Save codeactual/f170df76c4010d297f74c88af97fd88c to your computer and use it in GitHub Desktop.

Select an option

Save codeactual/f170df76c4010d297f74c88af97fd88c 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