It's a lean boilerplate to start developing a microservice in Go.
- Gin server
- Godotenv to load environment variables
- Makefile for the development and production tasks
- Air live reload configuration
- Docker configuration
- Docker-compose configuration
The project layout follows the Standard Go Project Layout.
I adopted the godotenv to load environment variables, following this convention.
In the Makefile there are the commands to develop and build:
make dev
: run the app with live reload (Air)make
: format, lint, examine and buildmake start
: start the server in production mode
Build
docker build -t go_app -f .\build\package\Dockerfile .
Run
docker run -p 8080:8080 go_app:latest
Docker compose up
docker-compose -f .\docker-compose.yml up -d --build
Docker compose down
docker-compose -f .\docker-compose.yml down
To easily install the latest version of GNU Make for Windows, you may execute scoop install make
(Scoop) or choco install make
(Chocolatey).
To install globally Air for the live reload, execute go install github.com/cosmtrek/air@latest
.