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
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
Can be accessed at http://localhost:8080/. Check the API documentation below for endpoints.
Can be accessed on http://localhost:8081/healthcheck
Can be viewed on http://localhost:8085/swagger/index.html after being generated by running make docs
The development setup depends on the following tools:
- go
- docker
- docker-compose
- golangci-lint
- swaggo
To install all go dependencies run make deps
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