Govern
A lightweight, production-ready Go library for building robust HTTP services with graceful shutdown, database management, JWT authentication, logging, metrics, and health checks.
Installation
go get github.com/haipham22/govern
Features
| Package | Description |
|---|---|
config |
Configuration loading with YAML, .env, and ENV variables |
http |
HTTP server with graceful shutdown and middleware |
http/echo |
Echo utilities: JWT middleware, Swagger integration, handler wrapping |
http/jwt |
JWT authentication middleware and token management |
http/middleware |
Common HTTP middleware (logging, recovery, CORS, request ID) |
graceful |
Goroutine and process management with graceful shutdown |
database/postgres |
PostgreSQL connection management with GORM |
database/redis |
Redis connection management with connection pooling |
cron |
Cron scheduler with gocron v2, graceful lifecycle (Phase 1: Handler & Session complete) |
mq/asynq |
Asynq integration with Redis message queue (Phase 2: Client implementation complete) |
errors |
Structured error handling with error codes |
log |
Zap-based structured logging |
metrics |
Prometheus metrics with HTTP middleware |
healthcheck |
Health check registry for liveness/readiness probes |
retry |
Flexible retry logic with backoff strategies |
Quick Start
See QUICKSTART.md for installation and usage examples.
Comprehensive Documentation
For detailed documentation, see the docs/ directory:
- Project Overview & PDR - Project overview and requirements
- Codebase Summary - Comprehensive codebase analysis
- Code Standards - Coding standards and conventions
- System Architecture - Architecture and design patterns
- Deployment Guide - Deployment instructions
Roadmap
Phase 1: Core Functionality
- Graceful server shutdown
- PostgreSQL connection management
- Structured error handling
- Zap-based logging package
Phase 2: Enhancement
- Metrics integration (Prometheus)
- Health check utilities
- Retry logic
- HTTP server with middleware
Phase 3: Ecosystem
- Echo utilities (JWT, Swagger, handler wrapping)
- JWT authentication
- UniversalClient interface tests
- Cron scheduler Phase 1 (Handler & Session interfaces)
- Asynq integration Phase 2 (Client implementation)
- Circuit breaker pattern
- Additional framework integrations (gin, fiber)
Requirements
- Go 1.25 or 1.26
Development
See DEVELOPMENT.md for development setup, testing, and contribution guidelines.
License
TBD
Repository: https://github.com/haipham22/govern