MicroserviceTemplate

module
v0.0.0-...-b56c44a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 16, 2020 License: MIT

README

Build Status Go Report Card Codacy Badge Quality Gate Status Coverage
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.

References

This project is inspired by multiple blogs and guides on best practices while writing Go code. I'm sharing links to these below.

Project Structure

  1. How to Write Go Code
  2. golang-standards/project-layout
  3. Organizing Database Access

Documentation

  1. Documenting APIs with Swagger
  2. Documenting Go Code

Containerization

  1. Docker: Multi-Stage Builds
  2. Why You Should Use Microservices and Containers

Testing

  1. Structuring Tests in Go
  2. Testing Web-Apps in Go

Getting Started

Clone the Repo

$ git clone https://github.com/archit-p/MicroserviceTemplate

Build and Run

$ 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

Project Layout

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)

Docs

Once the service is running, accompanying Swagger docs can be found at http://localhost:8080/swagger/index.html.

Contributing

Feel free to fork the project for use as a base template for your next microservice or REST API!

Built Using

Golang MongoDB Docker

Directories

Path Synopsis
cmd
web
pkg
dto

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL