Created
October 13, 2021 17:53
-
-
Save kralicky/5e579ff0ba91b15e55c9b8dab8973fc9 to your computer and use it in GitHub Desktop.
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 | |
set -e | |
if [ $# -ne 1 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then | |
echo "usage: update-go <version>" | |
exit 1 | |
fi | |
cur_version="$(go version | awk '{print $3}' | sed 's/go//')" | |
if [ "$cur_version" = "$1" ]; then | |
echo "already using this version" | |
exit 1 | |
fi | |
if [ ! -d "$HOME/sdk/go${1}" ]; then | |
go install golang.org/dl/go${1}@latest | |
eval go${1} download | |
else | |
echo "version already downloaded" | |
fi | |
rm -f "$HOME/sdk/latest" | |
ln -s "$HOME/sdk/go${1}" "$HOME/sdk/latest" | |
go version |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment