Last active
December 23, 2023 00:33
-
-
Save jniltinho/8fe13181e161cddda94a8e571a712da9 to your computer and use it in GitHub Desktop.
Update Golang *Nix
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 | |
## Update Golang (Linux/Mac) | |
/usr/local/go/bin/go version | |
LOCAL_VERSION=$(/usr/local/go/bin/go version|awk '{print $3}') | |
## Get Last Stable Version | |
LAST_VERSION=$(curl -s 'https://go.dev/VERSION?m=text'|head -n1) | |
OS="linux" | |
ARCH="amd64" | |
if [[ "$(uname -s)" == "Darwin" ]]; then | |
OS="darwin" | |
fi | |
if [[ "$(uname -m)" == "arm64" ]]; then | |
ARCH="arm64" | |
fi | |
if [[ "$LOCAL_VERSION" == "$LAST_VERSION" ]]; then | |
echo "Go is up to date" | |
exit 0 | |
fi | |
rm -rf /usr/local/go | |
curl -L --progress-bar "https://go.dev/dl/${LAST_VERSION}.$OS-$ARCH.tar.gz"|tar -C /usr/local/ -xzf - | |
/usr/local/go/bin/go version |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment