Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Simple script to toggle between Go versions.
echo "Available go versions:"
result=$(ls -1 /usr/local/ | grep -i "go" | grep -v "^go$")
echo "$result" | nl
echo ""
printf "Which version shall it be: "
read -r num
echo ""
goversion=$(echo "$result" | sed "${num}q;d")
if [ -z $goversion ]; then
echo "invalid input"
exit 1
sudo rm /usr/local/go
sudo ln -s "/usr/local/$goversion" /usr/local/go
go version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment