#!/bin/bash set -o errexit -o pipefail [[ "$GOROOT" ]] || export GOROOT="$HOME/golang" [[ "$GOPATH" ]] || export GOPATH="$HOME/go" PKG_VER="1.4.2" gimme \ curl \ git \ mercurial #TODO: might eventually make these two more similar if ! has go; then if [[ "$OS" = "Darwin" ]]; then GOROOT="" gimme_pkg go --with-cc-common else if ! [[ -d "$GOROOT" ]]; then PKG_URL="https://storage.googleapis.com/golang/go${PKG_VER}.linux-amd64.tar.gz" mkdir -p "$GOROOT.$PKG_VER" curl -k -fsSL "$PKG_URL" | tar -xz -C "$GOROOT.$PKG_VER" mv -v "$GOROOT.$PKG_VER/go" "$GOROOT" rm -fr "$GOROOT.$PKG_VER" else echo "# FAIL: Unable to install 'go' to the GOROOT=$GOROOT directory because it already exists." exit 123 fi fi fi