Skip to content

Instantly share code, notes, and snippets.

@denkhaus
Forked from jmervine/goinst.sh
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save denkhaus/d29e10eaebd445cbce52 to your computer and use it in GitHub Desktop.
Save denkhaus/d29e10eaebd445cbce52 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
#
# Example usage:
#
# $ VERSION=1.2.2 sudo ./goinst.sh
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
test "$VERSION" || VERSION=1.2.2
set -ex
TDIR=`mktemp -d`
#trap "{ cd - ; rm -rf $TDIR; exit 255; }" SIGINT
cd $TDIR
wget https://storage.googleapis.com/golang/go$VERSION.linux-amd64.tar.gz
rm -rf /usr/local/go
tar -C /usr/local -xzf go$VERSION.linux-amd64.tar.gz
echo 'export GOPATH=~/dev/gocentral' >> ~/.bashrc
echo 'export PATH=$PATH:$GOPATH/bin' >> ~/.bashrc
echo 'export PATH=/usr/local/go/bin:$PATH:$GOPATH/bin' >> /etc/profile.d/golang.sh
cd -
rm -rf $TDIR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment