This is a repository for creating a DDD style Go template.
Here implement some simple APIs to query MySQL DB and return the result from DB. And here would apply docker to pack Go API and DB in local. So you can try this project by your local site.
- A DDD style Go/ Gin API Backend
- Support Swagger (OpenAPI)
- Support Log Middleware
- R/W with MySQL Database via APIs
- Go 1.22.1
Our backend follows the DDD (Domain-Driven Design) structure to construct our Go lang backend system.
- Create a project folder
- Ensure you have Go installed and required versions (check by
go version
in your cli) - Use this commad to initialize your project in your project folder:
go mod init <project-owner>/<project-name>
- Gin
- Viper -> configurations
- Zap -> logger, and open to other repo using
build: make build
run: make run
build&run: make br
- setup the connection string of DB in
configs/go-template.json
- then makefile
make build
make run
- create an
.env
file to specify the variables for DB and Env - then execute
docker-compose up