for fast starting a microservice application on top of Gin framework.
Name | Description | Reference Link |
---|---|---|
config | configuration per env. including dev, sit, uat, prod etc | Yaml files |
apis/controllers | apis implementation | follow OpenAPI 3.0 specification |
apis/models | definition of request input models and response models | |
core | define application errors | |
core/middlewares | request middleware, interceptor, global error handler etc | |
core/logging | context logger | |
core/otel | initializer OTEL tracer, metric, logging provider | |
core/validators | initialize model fields validator, e.g Gender | |
core/enums | define enums, e.g Gender | |
infra | infra resources connectivity and management | |
infra/db | database connection, transaction | |
infra/mq | MQ connection | e.g. Kafka, RabbitMQ |
infra/cache | cache connection | e.g. Redis |
jobs | schedule jobs implementation | e.g. cron job |
messaging | event-driven integration between micro-services | |
messaging/events | definition of events | follow cloud event specification |
messaging/consumers | consumer implementation, calling domain service methods | |
migrations | database schema changes | |
persistence/entity | data entity mapping to database schema | |
persistence/repository | data handling over database | using Context to manage transaction |
server | implement routers, server, CDI | |
services | business login implementation | using Context to manage transaction |
wire-config | CDI initializer |
in General, migration files should be put in a dedicated repo, and run with a dedicated restricted User.
[JWT](https://github.com/golang-jwt/jwt https://github.com/MicahParks/keyfunc)
[ACL casbin] (https://casbin.org/)
Repository SHOULD return error, SHOULD NOT Panic.
Service MUST Panic if error and NEED to stop execution.
Global Recovery/Defer function SHOULD handle error and response.
Always set DEFAULT value on database table column, so that can avoid can't convert from NULL to yyy error
git config core.hooksPath .git-hooks
Golangci-lint aggregates dozens of tools with hundreds of checks. Revive is one of such tools