Boilerplates for getting started with an HTTP Service/API in Go.
This project follows the Standard Go Project layout from golang-standards/project-layout
When I first started looking into creating cleaner HTTP services I stumbled upon Mat Ryer's How I write Go HTTP services after seven years. I found his blog post inspiring and decided the emulate most of his recommendations.
The Dockerfile has 3 steps: The first one builds your application, the second one is meant for testing, and the final step produces a small image from scratch. As best practice the final image runs as non-root.
A Makefile contains a set of directives that helps developers use and understand your application.
> make help
Choose a command to run in go-start-http-api:
run Runs your application
install Installs your dependencies
build Builds your application
test Runs your tests if any
cover Checks your code coverage
I wrote a simple package to help with sending JSON error and success responses. Ckeck it out!
I've been using a similar code structure for the past ~2 years and wanted to share it with the community. Feedback is more than welcome :) Feel free to create Github Issues and Pull requests as you see fit.