A module template for golang.
-
adapter/
Adaptation layer code for external interaction, such as RESTful API definition and command line definition. -
configs/
Configuration files. -
docs/
Document directory generated by swagger. -
domain/
Domain model definition and implementation. -
infra/
Infrastructure code that implements external dependencies, such as database access object, etc. -
pkg/
Functional packages, such as util functions, injection functions, dto definitions, etc. -
service/
Service layer code implements the main business processes. -
go.mod
,go.sum
Go module definition and dependency lock files. -
main.go
Main program, code entrance. -
README.md
Project documentation.
This template follows the standard Go project layout, making it easy to start new Go modules with best practices.
1. Update dependency
- go mod tidy
2. Generate inject files
- wire ./...
3. Generate swagger files
- swag init
visit http://localhost:8001/swagger/index.html
4. Build
- go build
5. Run
- ./template