Skip to content

Instantly share code, notes, and snippets.

@nevkontakte
Created June 19, 2021 14:46
Show Gist options
  • Save nevkontakte/4645116e61daab9216ef1e5987cf5fb9 to your computer and use it in GitHub Desktop.
Save nevkontakte/4645116e61daab9216ef1e5987cf5fb9 to your computer and use it in GitHub Desktop.
A little helper script to help updating Go toolchain version on Linux.
#!/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