Created
November 9, 2022 19:06
-
-
Save codeliger/4061df95d458769ee5c3c8a60cd66de3 to your computer and use it in GitHub Desktop.
A function for .bashrc to update go to latest version
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
function updatego(){ | |
GOVERSION=`git ls-remote --tags https://go.googlesource.com/go | grep -E "refs\/tags\/go[[:digit:]]*\.[[:digit:]]*(\.[[:digit:]]*)?$" | cut -f2 -- | sort -V | tail -n 1 | cut -d'/' -f3` | |
FILENAME=$GOVERSION.linux-amd64.tar.gz | |
FILEPATH="/home/$USER/$FILENAME" | |
URL=https://golang.org/dl/$FILENAME | |
echo "Downloading $URL" | |
echo "Saving to $FILEPATH" | |
echo "wget -nc -c -O $FILEPATH $URL" | |
wget -nc -c -O $FILEPATH $URL | |
sudo rm -rf /usr/local/go | |
sudo tar -C /usr/local -xzf $FILEPATH | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment