stubsrv
is a skeleton application in Go for building simple services.
- labstack/echo high performance, minimalist Go web framework
- BurntSushi/toml TOML config parser
- go-pg/pg PostgreSQL ORM for with focus on PostgreSQL features and performance
- prometheus/client_golang Prometheus instrumentation library for Go applications
- Testing: smartystreets/goconvey
- Vendoring: rancher/trash
- Static analyzer: staticcheck
This sample app was created as proof-of-concept template for new services
. It uses proven packages and following
Twelve-Factor App principles.
make tools
installs goconvey, trash and staticcheck into yourGOPATH
make fix
runsgo get .
make vet
runsgo vet
andstaticcheck
make fmt
runsgofmt
make deps
runstrash
for vendor.conf (don't forget to specify correct versions of libraries)make build
ormake rebuild
builds or rebuilds your appmake run
runs app in verbose mode with defaultconfig.cfg
make test
ormake test-short
runsgo test
(with or without -test.short flag)make convey
runsgoconvey
for testing and code coverage.
- Set correct database credentials in config.cfg
- run
make run
- open browser at http://localhost:8080/sample-url and you will see bloated tables in your database :).
Also you can check:
- http://localhost:8080/debug/pprof/ standard /debug/pprof handler
- http://localhost:8080/metrics url for Prometheus collector
- basic structure and code organization
- TOML configs
- standard log.Logger usage with two levels: debug & error
- working with PostgreSQL database
- working with labstack/echo
- working with metrics via Prometheus (labstack/echo metrics as middleware)
- working with tests via goconvey
- vendoring example via trash
This project is released under the MIT license.