Created
June 19, 2021 14:46
-
-
Save nevkontakte/4645116e61daab9216ef1e5987cf5fb9 to your computer and use it in GitHub Desktop.
A little helper script to help updating Go toolchain version on Linux.
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 [[ "$1" != "" ]]; then | |
VERSION="go${1}.linux-amd64" | |
else | |
VERSION="$(curl -s -S https://golang.org/VERSION?m=text).linux-amd64"; | |
fi | |
export PATH="/usr/local/go/bin:${PATH}"; | |
echo "Current Go: $(go version)"; | |
echo "Upgrading to: ${VERSION}"; | |
test -x "./go" && rm "./go"; | |
test -d "${VERSION}" && rm -r "${VERSION}" | |
wget -c -nv "https://dl.google.com/go/${VERSION}.tar.gz"; | |
tar -xzf "${VERSION}.tar.gz"; | |
test -d "./go"; | |
mv "./go" "./${VERSION}"; | |
test -d "./${VERSION}"; | |
ln -s "./${VERSION}" "./go"; | |
rm "${VERSION}.tar.gz"; | |
echo "Upgraded Go: $(go version)"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment