Skip to content

Instantly share code, notes, and snippets.

@bgentry
Forked from denkhaus/goinst.sh
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bgentry/3f508a2c6cb6417ad46c to your computer and use it in GitHub Desktop.
Save bgentry/3f508a2c6cb6417ad46c 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
export GOPATH=~/dev/gocentral
echo "export GOPATH=$GOPATH" > /etc/profile.d/golang.sh
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