Giter VIP home page Giter VIP logo

go-microservice-template's Introduction

Go Reference Go Report Card

Description

go-microservice-template main purpose is to be a starting point for a REST API in Go. Reducing boilerplate writing and speeding up development of new microservices

How to use

  1. Clone repository.
  2. Delete LICENSE and .git.
  3. Rename module name on go.mod.
  4. Rename the module reference of local packages inside server/ and main.go with the new module name. Example:
import ( 
    // rename with you module name
    "github.com/bruno-chavez/go-microservice-template/handlers"
    "github.com/julienschmidt/httprouter"
    "net/http"
    "os"
    "time"
)
  1. Rename the .env.example file to .env and customize the parameters accordingly.

Features

  • Fast and easy to use router with julienschmidt/httprouter.
  • Ready to use Dockerfile for building a secure and small Docker Image.
  • Graceful shutdown out of the box.
  • Environment variables loading from an .env file with the help of godotenv.
  • Dependency management with Go Modules.
  • Optional CORS handling with rs/cors, see server/server.go for how to enable it.

Continuous Integration

go-microservice-template currently, it uses Github Actions for linting, testing and building the microservice. Current workflow:

  • Lints with golangci-lint.
  • Run unit tests and prints the results with tparse.
  • Builds binary.
  • Builds Docker Image.

See ci.yml for more info.

Notes

  • Previously the module was called go-web-template, it lacked any kind of meaningful updates and was too opinionated for its purpose. I decided to complete refactor it and came up with the current iteration of go-microservice-template.

Contribute

Found a bug or an error? Post it in the issue tracker.

Want to add an awesome new feature? Fork this repository, add the feature on a new branch, send a pull request!

License

The MIT License (MIT) Copyright (c) 2021 Bruno Chavez

go-microservice-template's People

Contributors

bruno-chavez avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.