Last active
October 26, 2023 15:07
-
-
Save navossoc/f77070014de9e899e271440e0cd9f8ec to your computer and use it in GitHub Desktop.
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 | |
set -eu | |
LATEST=$(curl -fsL https://golang.org/VERSION?m=text) | |
LATEST=$(echo $LATEST | sed -r 's/go([0-9.]+) time.*\b/\1/') | |
echo "Latest version: $LATEST" | |
echo | |
VERSION=${VERSION:-$LATEST} | |
OS=${OS:-linux} | |
ARCH=${ARCH:-amd64} | |
echo Version: $VERSION | |
echo OS: $OS | |
echo Arch: $ARCH | |
echo | |
FILENAME=$VERSION.$OS-$ARCH | |
echo Downloading $FILENAME... | |
echo | |
curl https://dl.google.com/go/go$FILENAME.tar.gz -# -o /tmp/go.tar.gz | |
echo Uninstall old version... | |
echo | |
sudo rm -rf /usr/local/go/ | |
echo Installing new version... | |
echo | |
sudo tar -C /usr/local -xzf /tmp/go.tar.gz | |
rm -rf /tmp/go.tar.gz | |
#export PATH=$PATH:/usr/local/go/bin | |
go version |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment