module
0.0.0-20240806164408-8a51e34afa6f
Repository: https://github.com/thinhlh/go-web-101.git
Documentation: pkg.go.dev
# README
Golang microservice Template
Prerequisite
- Docker/Docker compose
- Golang
- Makefile (optional)
- Copy env
cp .env.example .env
Boot
- Local (Boot whole stack)
make run
- Dev
make pre-run make services-dev
- Prod
make pre-run make services
A production ready GoLabg template with Domain Driven Design architecture and predefined configurations
Features
- Environment configuration
- Built in exception filter
- Base RestAPI response
- SQL database connection
- Commithook & commitlint
- Error handling
- Database migration
- Body compression
Environment configuration
Built-in exception filter
Base universial RestAPI response with OpenAPI support
SQL Database connection with TypeORM
Commithook & commitlint
Error handling
Database migration
TODO items
-
Server Configs
- Cors
- Healthcheck (Heartbeat middleware)
- Profiller
- Api Rate limiter
-
Application Configs
- Domain Driven architecture
- Application load config from file & env
- Microservices project architecture
- Base response for RestAPI
-
Deployments
-
Others
-
Database migration
- Using gorm AutoMigration
- Does not have versioning strategy - Does not support rollback - Does not isolate between infrastructure & application + Suggest using other tools that run migration before running application // https://www.reddit.com/r/golang/comments/12mypec/how_do_you_handle_migrations/
- Current solution: Using golang-migration. Need to add a docker-compose version
- No tracking & schema -> sql generation - Have to write SQL up & down manually + Separation of concern
Usage
make migration-create migration_msg="create_table_product" # Create new migration then filling up & down sql script make migration-up step= # Up migration. step=N/"" for N step up or all up make migration-down step= # Down migration. step=N/"-all" for N step down or all down
-
Linting & Commit Lint
-
Business Error handling
-
Sample CRUD
-
CI/CD pipeline
-
CQRS
-
BaseModule, BaseCRUD
-
Pagination
-
Locking mechanism
-
Feature flag
-
HttpServices
-
Auth
-
Logging, Tracing & Monitoring
-
Deployment
-
Caching
-
MessageQueue
-
GraphQL
-
gRPC
-
Monorepo
-
CMS Integration
-
High-level application architecture docs