Here is a good starting point for GoSublime:
"on_save": [{
"cmd": "gs9o_open", "args": {
"run": ["sh",
"errcheck && go build . errors && go test -i && go test && go vet && golint ."],
"focus_view": false
}}],
"autocomplete_closures": true,
"complete_builtins": true,
You'll need the relevant Go tools available for this to work. Errcheck can be found here.
- Clone this repository into your GOPATH.
- Run
scripts/tools.sh
to get thegolint
anderrcheck
tools if you don't have them. - Drop the .git folder.
- Rename the goberry package with
scripts/rename.sh <package>
. - Design your RAML API interface.
- Run
raml-gen
which will generate HTTP handlers for your service. - Copy the generated
handlers_gen.go
file tohandlers.go
. - Run
git init
. - Run ```submodule_init.sh.
- Run
git add .
andgit commit -m "initial commit"
. - Run
make build
to build a local version of the binary in the service folder. - Run
make buildx
to build a production (Linux) version o the binary. - The ramlapi package will wire up your endpoints to the handlers.
- Now build out your service.
- Run
source dev_env
to configure environment.
The comprehensive Makefile allows you to:
make build
- build binary.make buildx
- build binary for deployment (Linux).make tools
- getgolint
anderrcheck
tools if needed.make clean
- remove binaries.make lint
- run linter recursively.make vet
- rungo vet
recursively.make fmt
- rungo fmt
recursively.make test
- rungo test
in vervbose mode recursively.make race
- rungo test
recursively with the race flag on.make env
- dump your Go enviroment variables.
We are aiming to make our microservices 12 factor
The make builders build the binary as follows:
go build -ldflags "-X main.buildstamp `date -u '+%Y-%m-%d_%I:%M:%S%p'` -X main.githash `git rev-parse HEAD`"
The build date and commit hash are then made available via the /version endpont.
We use gobundle to bundle assets (for now, just api.raml) with the binary. To bundle an updated RAML file:
- Make sure BUNDLE_ASSETS=1 is included in your
dev_env
file.
Run go get github.com/alecthomas/gobundle/gobundle
Run gobundle --compress --uncompress_on_init --package=main --target=bundle.go "api.raml"
By default this is off in goberry so you can adapt your RAML file as necessary when you create a new service and then bundle it up.
Run make test
for boring old black and white test output.
Run ./pride
to get nicely colorized test output.
The goconsul.json file is present to hook up to a package being built to plug into consul
Run scripts/pythia to run the browser-based UI built on top of the Oracle code analysis tool and godoc.
This codebase provides low level metrics using the built-in expvar package. Simply navigate to /debug/vars to see basic memory allocation and stack use information.
If you'd like to use Docker for your build you'll need to install Docker on your local machine. From there running ./build.sh
will create your docker container and start it locally if it passes the tests and linting in the ./test.sh
file. This uses the Dockerfile in the route folder and is based on the standard golang container.