Skip to content

Instantly share code, notes, and snippets.

@lovromazgon
Created June 13, 2018 07:35
Show Gist options
  • Save lovromazgon/78b3bc05383557a83a60cdf3419b7391 to your computer and use it in GitHub Desktop.
Save lovromazgon/78b3bc05383557a83a60cdf3419b7391 to your computer and use it in GitHub Desktop.
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