Downloads:
- https://binaries.rightscale.com/rsbin/go-boilerplate/master/go-boilerplate-linux-amd64.tgz
- https://binaries.rightscale.com/rsbin/go-boilerplate/master/go-boilerplate-darwin-amd64.tgz
- https://binaries.rightscale.com/rsbin/go-boilerplate/v0.1.0/go-boilerplate-linux-amd64.tgz
- https://binaries.rightscale.com/rsbin/go-boilerplate/v0.1.0/go-boilerplate-darwin-amd64.tgz
- Install Go 1.5
- Ensure your GOPATH is set such that $PWD == $GOPATH/src/github.com/rightscale/go-boilerplate
- You should set GO15VENDOREXPERIMENT=1 in your env, but you don't have to
- Install dependencies with
make depend
- Run tests using
make test
- Try it out:
make && ./go-boilerplate
The go-boilerplate is a simple web app that has a couple of handlers to index, get, put, delete key-value pairs in a hash table. The features of the repo are:
- Simple Makefile and .travis.yml for full lifecycle, from building, testing, code coverage, uploads of binaries to S3, badges in README
- Simple web app with logging, error handling, form parsing, and other middleware
- Uses the Go1.5 vendor experiment and glide to manage packages. To add a new dependency
use
glide get ...
like you wouldgo get
and check outglide up
to update packages to the latest version
$ curl -i http://localhost:8080/health-check
HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
Date: Sat, 26 Sep 2015 05:50:13 GMT
Content-Length: 49
go-boilerplate dev - 2015-09-25 22:47:25 - master
$ curl http://localhost:8080/demo/settings
{}
$ curl -XPUT http://localhost:8080/demo/settings/a?value=b
$ curl http://localhost:8080/demo/settings
{"a":"b"}
$
And the corresponding log output:
$ make && ./go-boilerplate
make: Nothing to be done for `default'.
[2015-09-25 22:49:52] INFO RightScale Go Boilerplate version="go-boilerplate dev - 2015-09-25 22:47:25 - master" pid=21653
[2015-09-25 22:50:13] DBUG GET /health-check
[2015-09-25 22:50:13] INFO /health-check verb=GET id=h/XemzFgiFHC-000001 ip=127.0.0.1:57786 time=79.222µs status=200
[2015-09-25 22:50:19] DBUG GET /demo/settings
[2015-09-25 22:50:19] INFO /demo/settings verb=GET id=h/XemzFgiFHC-000002 ip=127.0.0.1:57788 time=202.347µs status=200
[2015-09-25 22:50:23] DBUG PUT /demo/settings/a value=b
[2015-09-25 22:50:23] INFO /demo/settings/a verb=PUT id=h/XemzFgiFHC-000003 ip=127.0.0.1:57790 time=106.995µs status=0
[2015-09-25 22:50:27] DBUG GET /demo/settings
[2015-09-25 22:50:27] INFO /demo/settings verb=GET id=h/XemzFgiFHC-000004 ip=127.0.0.1:57792 time=76.967µs status=200