Skip to content

Instantly share code, notes, and snippets.

@nskondratev
Created April 16, 2019 05:48
Show Gist options
  • Save nskondratev/f316993f5486592c73711b0a9a274215 to your computer and use it in GitHub Desktop.
Save nskondratev/f316993f5486592c73711b0a9a274215 to your computer and use it in GitHub Desktop.
Bash script for updating/installing Go on linux
#!/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