Skip to content

Instantly share code, notes, and snippets.

@raggi
Created May 12, 2015 21:00
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 raggi/c26b9edd442073206021 to your computer and use it in GitHub Desktop.
Save raggi/c26b9edd442073206021 to your computer and use it in GitHub Desktop.
A "pure" Heroku buildpack for Golang, uses GOPATH, no Godep. Make in a repo with files under bin/detect and bin/compile
#!/bin/bash
BUILD_DIR=$1
CACHE_DIR=$2
ENV_DIR=$3
GOBALL=go1.4.1.linux-amd64.tar.gz
mkdir -p $CACHE_DIR
export PATH=$PATH:$CACHE_DIR/go/bin
build_go() {
cd $CACHE_DIR
if [[ ! -d go ]]; then
if [[ ! -r $GOBALL ]]; then
wget https://storage.googleapis.com/golang/$GOBALL
fi
tar zxf $GOBALL
rm $GOBALL
fi
}
build_app() {
cd $BUILD_DIR
export GOPATH=$BUILD_DIR
# TODO: make build targets configurable from metadata
go get ./...
go install ./...
}
echo '-----> Fetching Go'
build_go
echo '-----> Compiling go application'
build_app
#!/bin/bash
BUILD_DIR=$1
find ${BUILD_DIR}/src | grep '.go$' >/dev/null || exit 1
echo Go
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment