Skip to content

Instantly share code, notes, and snippets.

@igolaizola
Created September 18, 2020 07:37
Show Gist options
  • Save igolaizola/d45712538d38f077a2f7979053380130 to your computer and use it in GitHub Desktop.
Save igolaizola/d45712538d38f077a2f7979053380130 to your computer and use it in GitHub Desktop.
Bump Golang version (linux)
#!/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
@igolaizola
Copy link
Author

Execute script via curl

sh -c "$(curl -fsSL https://gist.githubusercontent.com/igolaizola/d45712538d38f077a2f7979053380130/raw)"

Execute script via wget

sh -c "$(wget https://gist.githubusercontent.com/igolaizola/d45712538d38f077a2f7979053380130/raw -O -)"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment