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 toolsinstalls goconvey, trash and staticcheck into yourGOPATHmake fixrunsgo get .make vetrunsgo vetandstaticcheckmake fmtrunsgofmtmake depsrunstrashfor vendor.conf (don't forget to specify correct versions of libraries)make buildormake rebuildbuilds or rebuilds your appmake runruns app in verbose mode with defaultconfig.cfgmake testormake test-shortrunsgo test(with or without -test.short flag)make conveyrunsgoconveyfor 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.