Skip to content
/ go-template Public template

Boilerplate template for a golang microservice

Notifications You must be signed in to change notification settings

efimovalex/go-template

Repository files navigation

CI-pipeline

Go Project Template

A flexible template that allows the quick starting of one or more new golang APIs, processing units or microservices.

Currently it is wired to start a single service

Introduction

Find and replace replaceme string in all project with your new project name for fast development start.

File structure:

  • ./ -> where the main file lives + configuration files + docker files
  • adapters -> adapters for external services & tools
  • config -> package which has the role of loading the starting config
  • docs -> swagger generated files
  • internal -> clearly defined internal packages
  • schema -> migrations for the used databases
  • services -> the servers and it's dependent services. one cmd main file starts one of the services

Services

Rest API

Can be accessed at http://localhost:8080/. Check the API documentation below for endpoints.

Healthcheck

Can be accessed on http://localhost:8081/healthcheck

API documentation

Can be viewed on http://localhost:8085/swagger/index.html after being generated by running make docs

Dependencies

The development setup depends on the following tools:

  • go
  • docker
  • docker-compose
  • golangci-lint
  • swaggo

To install all go dependencies run make deps

Operations

Make provides a interface to common development operations

$ make

Usage:
  make <target>

Targets:
  help        This help.
  test-ci     Runs the tests with coverage checks + lint
  test        Runs all tests normally
  lint        Runs the linter
  build       Builds go binary
  run         Runs main package
  docs        Generate swagger documentation json/yaml
  up          Starts docker containers for dependent services
  stop        Stops docker containers for dependent services
  down        Removes docker containers for dependent services
  deps        Fetches go dependencies
  clean       Removes all docker containers and volumes
  migration   Creates a new migration
  migrate     Runs migrations locally
  revert      Reverts migrations locally