Created
June 13, 2018 07:35
-
-
Save lovromazgon/78b3bc05383557a83a60cdf3419b7391 to your computer and use it in GitHub Desktop.
Simple script to toggle between Go versions.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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