Generate a Go web service with router, middleware, and database patterns
Create a Go web service template for:
Service Name: {{SERVICE_NAME}}
Router: {{ROUTER}} (Chi/Gin/Echo/stdlib)
Database: {{DATABASE}}
Features: {{FEATURES}}
Generate complete Go structure:
1. **Project Layout:**
- cmd/api/main.go
- internal/handlers/
- internal/models/
- internal/repository/
- internal/middleware/
- pkg/
2. **Main Entry (main.go):**
- Configuration loading
- Database connection
- Router setup
- Graceful shutdown
- Signal handling
3. **Handlers:**
- Handler interface
- HTTP handler functions
- Request parsing
- Response writing
- Error handling
4. **Middleware:**
- Logging middleware
- Authentication middleware
- CORS middleware
- Rate limiting
- Request ID
5. **Models:**
- Struct definitions
- Validation tags
- JSON serialization
- Database tags
6. **Repository Pattern:**
- Interface definitions
- Database implementations
- Mock implementations
- Transaction handling
7. **Configuration:**
- Viper/envconfig setup
- Environment variables
- Config struct
- Validation
8. **Testing:**
- Handler tests
- Repository tests
- Integration tests
- Testcontainers setup
9. **Build and Deploy:**
- Makefile
- Dockerfile (multi-stage)
- Docker Compose
Include health check and metrics endpoints.Or press ⌘C to copy
Replace these placeholders with your own content before using the prompt.
[{SERVICE_NAME][{ROUTER][{DATABASE][{FEATURES]