Created
November 27, 2023 22:14
-
-
Save jakefhyde/52170f41c69042a28b9336379f9ec1c1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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