Created
April 16, 2019 05:48
-
-
Save nskondratev/f316993f5486592c73711b0a9a274215 to your computer and use it in GitHub Desktop.
Bash script for updating/installing Go on 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 | |
GO_DOWNLOAD_URL=$1 | |
if [ -z "$GO_DOWNLOAD_URL" ]; then | |
echo 'URL to Go distributive must be provided' | |
exit 1 | |
fi | |
sudo true | |
echo "Downloading Go from $GO_DOWNLOAD_URL" | |
PREV_CWD=$(pwd) | |
ARCHIVE_NAME=${GO_DOWNLOAD_URL##*/} | |
cd /tmp | |
wget $GO_DOWNLOAD_URL | |
sudo tar -xvf $ARCHIVE_NAME | |
if [ -d /usr/local/go ]; then | |
sudo rm -rf /usr/local/go | |
fi | |
sudo mv go /usr/local | |
sudo rm $ARCHIVE_NAME | |
echo "Done, current Go version: $(go version)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment