Created
September 18, 2020 07:37
-
-
Save igolaizola/d45712538d38f077a2f7979053380130 to your computer and use it in GitHub Desktop.
Bump Golang version (linux)
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 | |
LATEST=$(curl -s https://golang.org/dl/ | grep ".linux-amd64.tar.gz</span>" | sed -e 's/.*go\(.*\).linux.*/\1/') | |
CURRENT=$(go version | sed -e 's/.*go\(.*\) linux.*/\1/') | |
if [ $LATEST = $CURRENT ]; then | |
echo Golang version is up to date: $LATEST | |
else | |
echo Updating golang from $CURRENT to $LATEST | |
wget https://dl.google.com/go/go$LATEST.linux-amd64.tar.gz | |
sudo rm -rf /usr/local/go | |
sudo tar -C /usr/local -xzf go$LATEST.linux-amd64.tar.gz | |
rm go$LATEST.linux-amd64.tar.gz | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Execute script via curl
Execute script via wget