Created
April 7, 2021 11:28
-
-
Save bencromwell/3909b597891962746cde79e1842f5efa to your computer and use it in GitHub Desktop.
upgrade Go to the latest available release
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 | |
CURRENT=$(go version | awk '{print $3}') | |
LATEST=$(curl --silent https://golang.org/VERSION?m=text) | |
if [[ "${CURRENT}" == "${LATEST}" ]]; then | |
echo "You're already using the latest version: ${CURRENT}" | |
exit 0 | |
fi | |
TGZ="${LATEST}.linux-amd64.tar.gz" | |
wget https://golang.org/dl/${TGZ} | |
if [[ $? -ne 0 ]]; then | |
echo "Failed to download" | |
exit 1 | |
fi | |
sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf ${TGZ} | |
rm ${TGZ} | |
go version |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment