MadeiraMadeira boilerplate project to build scalable, testable and high performance Go microservices.

Overview

Core APIs Go Service Template

MadeiraMadeira boilerplate project to build scalable, testable and high performance Go microservices.

Table of Contents

Stack

Features

  • Automatic pre-commit code analysis and lint with golint, govet and goimports;
  • Automatic pre-push testing;
  • configuration: easily manage environment variables and app configuration;
    • it reads a .env file when its available, and load system variables when it's not;
    • it also validates the available variables based on the AppConfig struct;
  • healthcheck: REST endpoint that returns relevant information about the application status;
  • logger: easily manage application logs following the MMRFC1 standards;
  • Docker infrastructure with Docker Compose.

Getting started with boilerplate

Download and extract the project, then:

$ mv go-service-template-production {your_project_name}
$ git init
$ git remote add origin https://github.com/{user}/{repo}.git

Hint: use $ git remote -v to verify new remote

Hands On

Development

Docker setup

$ ./tools/setup.sh
$ docker-compose -f docker-compose.yml up

Local setup

$ ./tools/setup.sh
$ go mod download
$ go run ./cmd/SERVICE_NAME/main.go

# eg:
$ go run ./cmd/go_service_template/main.go

Test

# unit tests
$ go test ./...

# e2e tests
[soon]

# test coverage
[soon]

Improve tests output

To see a more friendly test output, install gotestsum globally by running

$ go install gotest.tools/gotestsum@latest

And execute in project root directory.

$ gotestsum --format testname 

Release

$ docker build \
    --target release \
    --build-arg SERVICE_PATH=_SERVICE_NAME_ \
    -t _SERVICE_NAME_:VERSION \
    -f docker/Dockerfile .

# eg:
$ docker build \
    --target release \
    --build-arg SERVICE_PATH=go_service_template \
    -t go-service-template-production:latest \
    -f docker/Dockerfile .

Squad Core APIs • MadeiraMadeira

Comments
  • docs: removed the squad name from the readme

    docs: removed the squad name from the readme

    We want to encourage other squads to contribute with our templates. It is good that everyone sees these templates as a company thing and not attached to one squad or another. It would be nice to remove the [COREAPI-XXXX] from the PR template as well.

    Remember guys, these are only suggestions. I want to encourage people to collaborate more.

    Proposed changes

    Change the readme text to be more neutral

    Checklist

    • [ ] Have you written tests for your changes?
    • [ ] Have you successfully run tests with your changes locally?
    • [ ] Have you lint your code locally prior to submission?
    opened by diegobcaetano 2
  • Ff 1471

    Ff 1471

    [COREAPI-XXXX]

    Proposed changes

    Describe your changes briefly and objectively.

    • Foo
    • Bar
    • Baz

    Checklist

    • [ ] Have you written tests for your changes?
    • [ ] Have you successfully run tests with your changes locally?
    • [ ] Have you lint your code locally prior to submission?
    opened by eversonbueno 1
  • Docker collision + setup improves

    Docker collision + setup improves

    Proposed changes

    • Docker compose file back to root dir to avoid services collision between projects.
    • Move setup bash to tools.
    • Setup bash create hooks symlink stand of copy.
    • Add project rename in setup bash.

    Checklist

    • [ ] Have you written tests for your changes?
    • [ ] Have you successfully run tests with your changes locally?
    • [ ] Have you lint your code locally prior to submission?
    opened by budnieswski 1
  • Inclusão de action para guidelines

    Inclusão de action para guidelines

    Proposed changes

    Inclusão de uma action para verificar os guidelines do projeto. Inclusão de uma action para execução do sonar. Pequena correção de nome de projeto no arquivo de setup devido ao projeto ter sido renomeado.

    Checklist

    • [ ] Have you written tests for your changes?
    • [ ] Have you successfully run tests with your changes locally?
    • [ ] Have you lint your code locally prior to submission?
    opened by andersoncontreira 0
  • Improving logger

    Improving logger

    Proposed changes

    • Add a logger interface to allow mocking for unit tests;
    • Improve the pre-commit hook to run go vet for whole packages instead of single files (avoid import errors);
    • Improve directory structure and file names;
    • Add an example of mock at health_check_handler_test.go;
    • Move go funk to direct dependecies (closes https://github.com/madeiramadeirabr/template-service-go/issues/24).

    Checklist

    • [x] Have you written tests for your changes?
    • [x] Have you successfully run tests with your changes locally?
    • [x] Have you lint your code locally prior to submission?
    opened by GuilhermeMLS 0
  • Removing common utils

    Removing common utils

    Proposed changes

    • Remove common utils (goodbye Fck() 🙁).

    Checklist

    • [ ] Have you written tests for your changes?
    • [ ] Have you successfully run tests with your changes locally?
    • [ ] Have you lint your code locally prior to submission?
    opened by GuilhermeMLS 0
  • feat: pre-commit hook

    feat: pre-commit hook

    Proposed changes

    • Pre-commit hook exclude deleted files when filter changes.

    Checklist

    • [ ] Have you written tests for your changes?
    • [ ] Have you successfully run tests with your changes locally?
    • [ ] Have you lint your code locally prior to submission?
    opened by budnieswski 0
  • Improve logger and fix some issues

    Improve logger and fix some issues

    Proposed changes

    • Add inline JSON message for non-development logs;
    • Fix health check directory name;
    • Improve README.

    Checklist

    • [x] Have you written tests for your changes?
    • [x] Have you successfully run tests with your changes locally?
    • [x] Have you lint your code locally prior to submission?
    opened by GuilhermeMLS 0
  • Follow ISO standards when logging timestamp

    Follow ISO standards when logging timestamp

    Proposed changes

    Necessary modification to comply with MMRFC1.

    Checklist

    • [ ] Have you written tests for your changes?
    • [x] Have you successfully run tests with your changes locally?
    • [x] Have you lint your code locally prior to submission?
    opened by GuilhermeMLS 0
  • Added router error handling

    Added router error handling

    Proposed changes

    Describe your changes briefly and objectively.

    • Added error handling for routes
    • Routes now catch panic error

    example :

    app.Get("/", func(c *fiber.Ctx) error {
        // 503 Service Unavailable
        return fiber.ErrServiceUnavailable
    
        // 503 On vacation!
        return fiber.NewError(fiber.StatusServiceUnavailable, "On vacation!")
    })
    

    or

    app.Get("/", func(c *fiber.Ctx) error {
            panic("This panic is caught by fiber")
        })
    

    Checklist

    • [ ] Have you written tests for your changes?
    • [x] Have you successfully run tests with your changes locally?
    • [x] Have you lint your code locally prior to submission?
    opened by ran-j 0
  • Adding alive endpoint

    Adding alive endpoint

    Proposed changes

    • Alive endpoint is used for the CloudOps team to set up the project infrastructure;
    • I've also sent the config pointer to the health check handler to improve our health check example.

    Checklist

    • [ ] Have you written tests for your changes?
    • [x] Have you successfully run tests with your changes locally?
    • [x] Have you lint your code locally prior to submission?
    opened by GuilhermeMLS 0
  • Ff 1471

    Ff 1471

    [COREAPI-XXXX]

    Proposed changes

    Describe your changes briefly and objectively.

    • Foo
    • Bar
    • Baz

    Checklist

    • [ ] Have you written tests for your changes?
    • [ ] Have you successfully run tests with your changes locally?
    • [ ] Have you lint your code locally prior to submission?
    opened by eversonbueno 4
  • Add catalog-info.yaml for Portal DX integration.

    Add catalog-info.yaml for Portal DX integration.

    Esta solicitação pull adiciona um arquivo de metadados de entidade Backstage a este repositório para que o componente possa ser adicionado ao catálogo de software da MadeiraMadeira no Portal DX.

    Depois que essa solicitação pull for mesclada, o componente ficará disponível.

    Sinta-se à vontade para fazer alterações no arquivo. Para mais informações, leia a documentação com as orientações específicas em Arquivo de Configuração no Confluence do DX Team.

    opened by portaldx-mm 1
  • CLI for scaffold generation

    CLI for scaffold generation

    It would be neat if we had a CLI for scaffold generation using this template. Developers could simply

    $ fooCli <project_name>
    

    and it automatically creates a project_name directory with the template in it.

    Nice to have: the CLI could also automatically create a GitHub repo with all CI/CD pipeline setup.

    opened by GuilhermeMLS 0
  • Automatic Swagger Docs generation

    Automatic Swagger Docs generation

    The template project should have a basic setup for automatic Swagger docs generation, that can be used by projects later.

    Idea: there's a handy lib called Swag that could help achieving this using godoc (you simply comment the handler functions and the Swagger docs gets automatically generated). This can be added to a Makefile or even the CI/CD pipeline.

    opened by GuilhermeMLS 0
  • Test tables for unit testing

    Test tables for unit testing

    Test tables are an elegant way of reducing the amount of duplicated code when unit testing. The template project could have some test table examples.

    func TestFoo(t *testing.T) {
    	testTable := []struct {
    		testName string
    		expectedErr error
    		// add more variables to the test case here
    	} {
    		{
    			testName: "it should foo bar baz",
    			expectedErr: errors.New("foo"),
    		},
    	}
    	for _, testCase := range testTable {
    		t.Run(testCase.testName, func(t *testing.T) {
    			// Arrange
    			
    			// Act
    			
    			// Assert
    		})
    	}
    }
    

    Notice that test tables don't completely replace normal test cases. There are moments we simply should not use test tables.

    opened by GuilhermeMLS 0
Owner
Madeira Madeira
Madeira Madeira
Box is an incrementally adoptable tool for building scalable, cloud native, microservices.

Box is a tool for building scalable microservices from predefined templates. Box is currently in Beta so if you find any issues or have some ideas

null 1 Feb 3, 2022
Go-kit-microservices - Example microservices implemented with Go Kit

Go Kit Microservices Example microservices implemented with go kit, a programmin

Hao-Ming, Hsu 1 Jan 18, 2022
This is demo / sample / example project using microservices architecture for Online Food Delivery App.

Microservices This is demo / sample / example project using microservices architecture for Online Food Delivery App. Architecture Services menu-servic

Nurali Virani 1 Nov 21, 2022
Kitex byte-dance internal Golang microservice RPC framework with high performance and strong scalability, customized extensions for byte internal.

Kitex 字节跳动内部的 Golang 微服务 RPC 框架,具有高性能、强可扩展的特点,针对字节内部做了定制扩展。

CloudWeGo 5.4k Jan 9, 2023
Microservice Boilerplate for Golang with gRPC and RESTful API. Multiple database and client supported

Go Microservice Starter A boilerplate for flexible Go microservice. Table of contents Features Installation Todo List Folder Structures Features: Mult

Ahmad Saugi 14 Jul 28, 2022
High Performance Remote Object Service Engine

=============== Hprose is a High Performance Remote Object Service Engine. It is a modern, lightweight, cross-language, cross-platform, object-oriente

小马哥 615 Nov 3, 2022
Nano - Lightweight, facility, high performance golang based game server framework

Nano Nano is an easy to use, fast, lightweight game server networking library fo

Lonng 2.2k Jan 1, 2023
Trying to build an Ecommerce Microservice in Golang and Will try to make it Cloud Native - Learning Example extending the project of Nic Jackson

Golang Server Project Best Practices Dependency Injection :- In simple words, we want our functions and packages to receive the objects they depend on

Ujjwal Sharma 35 Nov 28, 2022
Rpcx-framework - An RPC microservices framework based on rpcx, simple and easy to use, ultra fast and efficient, powerful, service discovery, service governance, service layering, version control, routing label registration.

RPCX Framework An RPC microservices framework based on rpcx. Features: simple and easy to use, ultra fast and efficient, powerful, service discovery,

ZYallers 1 Jan 5, 2022
It's a lean boilerplate to start developing a microservice in Go.

Go microservice starter It's a lean boilerplate to start developing a microservice in Go. Features Gin server Godotenv to load environment variables M

itacode 0 Dec 27, 2021
Gecho-starter - A starter/boilerplate for Golang Echo API

gecho-starter gecho-starter is a boilerplate for writing services in Golang quic

Jesse Pham 5 Jul 24, 2022
Wake up, Samurai. We have a project to build

kyoto uikit UIKit for rapid development Requirements kyoto page configured SSA basic knowledge of kyoto (twui only) configured tailwindcss Installatio

Kyoto Framework 22 Jun 27, 2022
This project extends the go-chi router to support OpenAPI 3, bringing to you a simple interface to build a router conforming your API contract.

Go OpenAPI This project extends the go-chi router to support OpenAPI 3, bringing to you a simple interface to build a router conforming your API contr

Tiago Angelo 2 Mar 27, 2022
Design-based APIs and microservices in Go

Goa is a framework for building micro-services and APIs in Go using a unique design-first approach. Overview Goa takes a different approach to buildin

Goa 5k Jan 5, 2023
Sample cloud-native application with 10 microservices showcasing Kubernetes, Istio, gRPC and OpenCensus.

Online Boutique is a cloud-native microservices demo application. Online Boutique consists of a 10-tier microservices application. The application is

Google Cloud Platform 13.5k Dec 31, 2022
Go microservices with REST, and gRPC using BFF pattern.

Go microservices with REST, and gRPC using BFF pattern. This repository contains backend services. Everything is dockerized and ready to

Oguzhan 152 Jan 4, 2023
TinyHat.Me: Microservices deployed with Kubernetes that enable users to propose hat pictures and try on hats from a user-curated database.

Click here to see the "buggy" version ?? The Scenario TinyHat.Me is an up and coming startup that provides an API to allow users to try on tiny hats v

Bit Project 5 Jun 17, 2022
This is an example to demonstrate implementation golang microservices using domain driven design principles and sugestions from go-kit

go-kit DDD Domain Driven Design is prevelent and rising standard for organizing your microservice code. This design architecture emphasis on Code orga

Sourabh Mandal 1 Feb 9, 2022
Istio - An open platform to connect, manage, and secure microservices

Istio An open platform to connect, manage, and secure microservices. For in-dept

null 0 Jan 5, 2022