Last active
December 31, 2019 13:58
-
-
Save fatih/11d752582c5bd508ffe18a2df57c6424 to your computer and use it in GitHub Desktop.
Switch between go version using https://github.com/golang/dl
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
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/go${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
@fatih cool and thanks for that. Keep sharing, I learn a lot from you :)