Skip to content

Instantly share code, notes, and snippets.

@higebu
Created October 3, 2015 13:04
Show Gist options
  • Save higebu/2047d6198880097f27ab to your computer and use it in GitHub Desktop.
Save higebu/2047d6198880097f27ab to your computer and use it in GitHub Desktop.
Script for golang installation
#!/bin/bash -e
GO_VERSION=1.5.1
dir=$(mktemp -d)
pushd $dir
# Remove old version
sudo rm -rf /usr/local/go
# Download new version
wget https://storage.googleapis.com/golang/go${GO_VERSION}.linux-amd64.tar.gz
# Extract into /usr/local
sudo tar -C /usr/local -xvf go${GO_VERSION}.linux-amd64.tar.gz
# Cleanup
popd
rm -rf ${dir}
# echo the commands for setting up environment variables
echo 'For the first time, you may want to run following command.
cat <<EOF >> $HOME/.profile
export PATH="/usr/local/go/bin:$PATH"
export GOROOT="/usr/local/go"
export GOPATH=$HOME/go
export PATH="$GOROOT/bin:$GOPATH/bin:$PATH"
EOF'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment