Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Simple script to toggle between Go versions.
#!/bin/bash
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
fi
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
You can’t perform that action at this time.