go-microservice

module
v0.0.0-...-f4b0e85 Latest Latest
Warning

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

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

README

Golang MongoDB
Build Status Go Report Card
Go Microservice built using best practices, ideal for use as a starter template. It features an extensible model - Sample - with support for CRUD operations for MongoDB.

References

The idea for this project came up after reading 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

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)

Running

The project ships with a Makefile to build and run the service.

> 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

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!

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