Skip to content

Instantly share code, notes, and snippets.

@scottjbarr
Last active June 8, 2016 09:20
Show Gist options
  • Select an option

  • Save scottjbarr/c364d4aca9bf9986ba36ec5c7ab320da to your computer and use it in GitHub Desktop.

Select an option

Save scottjbarr/c364d4aca9bf9986ba36ec5c7ab320da to your computer and use it in GitHub Desktop.
Install a particular version of Go on OS X. Assumes your Go versions are installed in ~/.go/versions. Setting your environment variables is up to you.
# Add Go related config here so you can source this file from ~/.bashrc
export GOPATH=$HOME/p/go
export PATH=$PATH:$GOPATH/bin
export GOROOT=~/.go/versions/go1.7beta1
export PATH=$GOROOT/bin:$PATH
#!/bin/bash
#
# Download and install a particular version of Go.
#
# Assumes versions are installed at ~/.go/versions/
#
# Author : Scott Barr
# Date : 23 Apr 2016
#
if [ $# -ne 1 ]; then
echo "Please supply Go version eg. go1.6.2"
exit 1
fi
cd ~/.go/versions
version=$1
if [ -d ${version} ]; then
echo "${version} already exists"
exit 2
fi
filename=${version}.darwin-amd64.tar.gz
url=https://storage.googleapis.com/golang/${filename}
wget ${url}
tar -zxf ${filename}
mv go ${version}
rm ${filename}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment