Skip to content

Instantly share code, notes, and snippets.

@thomas-scrace
Created December 13, 2016 18:02
Show Gist options
  • Save thomas-scrace/8893f19a67c5590192d453fa277e15f0 to your computer and use it in GitHub Desktop.
Save thomas-scrace/8893f19a67c5590192d453fa277e15f0 to your computer and use it in GitHub Desktop.
Download and install the golang tools. Change variables to suit your purposes.
#!/usr/bin/env bash
# Downloads the specified version of go, unpacks it,
# deletes any existing version, and installs the new
# one globally. Needs root.
set -e
INSTALLDIR=/usr/local
GOROOT=$INSTALLDIR/go
VERSION=1.7.4
OS=linux
ARCH=amd64
TARFILE=go$VERSION.$OS-$ARCH.tar.gz
URL=https://storage.googleapis.com/golang/$TARFILE
curl $URL -LO
if [ -d "$GOROOT" ]; then
rm -r $GOROOT
fi
tar -C $INSTALLDIR -xzf $TARFILE
echo "export PATH=\$PATH:$GOROOT/bin" >>/etc/profile
source /etc/profile
rm $TARFILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment