go-clean-template is a clean and scalable starter template for building backend applications in Go, following Clean Architecture principles. This template uses:
- Fiber v2 as a fast and lightweight web framework for building RESTful APIs
- GORM as the ORM for PostgreSQL database access
- Redis for caching to improve performance and reduce database load
- gRPC for high-performance RPC communication
- Docker Compose for easy setup of PostgreSQL and Redis services
- Clear separation of concerns with Clean Architecture
- High-performance HTTP handling with Fiber v2
- Robust database integration using GORM with PostgreSQL
- Caching support via Redis
- REST and gRPC APIs supported
- Data Transfer Objects (DTO) to manage data structure transformations between layers
- Swagger API documentation with automatic generation
- Ready-to-use Docker Compose setup for dependencies
Follow the steps below to set up and run the project:
-
Clone the repository:
git clone https://github.com/MingPV/clean-go-template.git cd clean-go-template
-
Install Go module dependencies:
go mod tidy
-
Rename the environment file and configure it:
cp .env.example .env
Open the
.env
file and fill in all required configuration values such as PostgreSQL credentials, Redis connection details, and any other environment-specific settings. -
Start PostgreSQL and Redis services using Docker Compose:
docker-compose up -d
-
Run the application:
go run ./cmd/app
-
Test:
go test ./pkg/routes
Swagger UI for the API documentation is available at: localhost:8080/api/v1/docs


/clean-go-template
├── cmd/
│ └── app/
│ └── main.go
├── docs/
│ └── v1/
├── internal/
│ ├── app/
│ ├── entities/
│ ├── order/
│ │ ├── handler/
│ │ ├── usecase/
│ │ ├── repository/
│ │ └── dto/
│ └── user/
├── pkg/
│ ├── config/
│ ├── database/
│ ├── middleware/
│ ├── redisclient/
│ ├── responses/
│ └── routes/
├── proto/
│ └── order/
├── utils/
├── .env.example
├── .gitignore
├── LICENSE
├── README.md
├── docker-compose.yaml
└── go.mod