Implementation of clean architecture in Go, Gin with dependency injection.
Clean architecture template with gin framework, go-fx as dependency container, gorm as orm for database related operations.
To learn about project structure and dependency injection please go through here
Want to ask something, contribute or be part of discussions, 💬 Join us on Discord server.
.env.example
to .env
docker-compose up -d
localhost:5000
to verify if the server works.5001
.If you are running without docker be sure database configuration is provided in .env
file and run go run . app:serve
Key | Value | Desc |
---|---|---|
SERVER_PORT |
5000 |
Port at which app runs |
ENV |
development,production |
App running Environment |
LOG_OUTPUT |
./server.log |
Output Directory to save logs |
LOG_LEVEL |
info |
Level for logging (check lib/logger.go:172) |
DB_USER |
username |
Database Username |
DB_PASS |
password |
Database Password |
DB_HOST |
0.0.0.0 |
Database Host |
DB_PORT |
3306 |
Database Port |
DB_NAME |
test |
Database Name |
JWT_SECRET |
secret |
JWT Token Secret key |
ADMINER_PORT |
5001 |
Adminer DB Port |
DEBUG_PORT |
5002 |
Port that delve debugger runs in |
⚓️ Add argument
p=host
if you want to run the migration runner from the host environment instead of docker environment. Check #19 for more details. eg;make p=host migrate-up
Command | Desc |
---|---|
make migrate-up |
runs migration up command |
make migrate-down |
runs migration down command |
make force |
Set particular version but don't run migration |
make goto |
Migrate to particular version |
make drop |
Drop everything inside database |
make create |
Create new migration file(up & down) |
production
) zap
5002
. Vs code configuration is at .vscode/launch.json
which will attach debugger to remote application. Learn More
go run . --help
Please open issues if you want the template to add some features that is not in todos. 🙇♂️
Create a PR with relevant information if you want to contribute in this template.