A clean Go API template with layered architecture, PostgreSQL integration, and versioned routing.
- Chi router with versioned endpoints (/v1)
- PostgreSQL with sqlc code generation
- Structured logging with slog
- Configuration management with envconfig
- CORS middleware
- User management endpoints
- Go 1.25+
- Docker
- Make
- Goose (for migrations)
Copy and configure the environment file:
cp .env.example .envSet your database credentials and port.
Start PostgreSQL container:
make p-upRun migrations:
make m-upmake buildmake runServer starts on the port defined in .env.
GET /v1/health- Health checkGET /v1/users- List active usersPOST /v1/users- Create userGET /v1/users/{id}- Get user by IDPUT /v1/users/{id}- Update userDELETE /v1/users/{id}- Deactivate user
Queries are in internal/database/queries/. After modifying, regenerate with:
make sqlcMIT