Go Microservice built using best practices, ideal for use as a starter template. It features an extensible model - Sample - with support for CRUD and Search operations for MongoDB.
This project is inspired by multiple blogs and guides on best practices while writing Go code. I'm sharing links to these below.
$ git clone https://github.com/archit-p/MicroserviceTemplate
$ make help
Run make <target> where target is
help: print out this message
build: build the executables
run: start a clean build, and run executable
test: run go tests
docs: build documentation
clean: clean executables and docs
$ make run
cmd (contains code for our apps)
|-+ web (server router and controllers)
pkg (contains reusable code)
|-+ dto (data-transfer objects)
|-+ models (database models)
|-+ mongodb (models for mongo-db)
|-+ docs (swagger documentation)
Once the service is running, accompanying Swagger docs can be found at http://localhost:8080/swagger/index.html
.
Feel free to fork the project for use as a base template for your next microservice or REST API!