#!/bin/bash
set -e -o pipefail -u

export PATH=$PATH:~/go/bin:~/bin
export GOROOT=~/go
export GOPATH=~
unset GIT_DIR
unset GIT_WORK_TREE

if [ ! -d ~/go ]; then
    pushd `pwd`
    cd ~
    wget -nv http://storage.googleapis.com/golang/go1.4.1.linux-amd64.tar.gz
    echo "3e871200e13c0b059b14866d428910de0a4c51ed  go1.4.1.linux-amd64.tar.gz" | sha1sum --check && tar -xzvf go1.4.1.linux-amd64.tar.gz
    go get github.com/tools/godep
    popd
fi

godep restore
go build
