An open API service indexing awesome lists of open source software.

https://github.com/efimovalex/go-template

Boilerplate template for a golang microservice
https://github.com/efimovalex/go-template

boilerplate boilerplate-template docker docker-compose golang rest-api swagger template-project

Last synced: 2 days ago
JSON representation

Boilerplate template for a golang microservice

Awesome Lists containing this project

README

          

[![CI-pipeline](https://github.com/efimovalex/go-template/actions/workflows/ci.yml/badge.svg)](https://github.com/efimovalex/go-template/actions/workflows/ci.yml)
# 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

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
```