module
Version:
v1.14.0
Opens a new window with list of versions in this module.
Published: Jul 30, 2026
License: MIT
Opens a new window with license information.
README
¶
Go Common

Shared Go package for common code across microservices.
Prerequisites
- Go 1.26+
- Node.js 22+ and npm 11+
Packages
| Package |
Description |
| config |
Configuration management and environment helpers |
| database |
PostgreSQL connection with GORM |
| jwt |
EdDSA token issuing and local validation |
| middleware |
Auth and security middleware for Gin |
| models |
Shared GORM database models |
| audit |
Security event logging |
| repository |
Shared repository implementations |
| handlers |
Common HTTP handler utilities |
| logger |
Structured logging with slog |
| metrics |
Prometheus metrics collection |
| server |
HTTP server with graceful shutdown |
| queue |
RabbitMQ pub/sub with reconnection, retries, and DLQ |
| health |
Dependency health checking |
| renderer |
HTML email templates and their subjects |
Quick Start
import (
"log"
"time"
"github.com/adeptry-app/go-common/config"
"github.com/adeptry-app/go-common/database"
"github.com/adeptry-app/go-common/health"
"github.com/adeptry-app/go-common/jwt"
"github.com/adeptry-app/go-common/middleware"
)
// Configuration
dbCfg := config.NewDatabaseConfig()
// Database
db, err := database.Connect(dbCfg)
if err != nil {
log.Fatalf("database: %v", err)
}
defer func() {
if err := database.CloseDB(db); err != nil {
log.Printf("failed to close database: %v", err)
}
}()
// Auth middleware. Only the auth service builds a jwt.Issuer; every other
// service takes public keys and its own audience, so it cannot mint tokens.
verifier, err := jwt.NewVerifier(config.GetEnvRequired("JWT_PUBLIC_KEYS"), jwt.AudiencePublicAPI)
if err != nil {
log.Fatalf("jwt verifier: %v", err)
}
authMiddleware := middleware.NewAuthMiddleware(verifier)
// Health checks
healthAgg := health.NewAggregator(3 * time.Second)
healthAgg.Register(health.NewPostgresChecker(db))
router.GET("/health", healthAgg.Handler())
Development
task ci:all # Run all CI checks
task test # Run tests
task lint # Run linter
task format # Format code
Services Using This Module
auth-service - Authentication and sessions
files-api - File upload/download with MinIO
messaging-api - Contact form and message queue
messaging-service - Email delivery worker
public-api - RPG backend API
ai-service - AI homebrew queue worker
License
MIT
Directories
¶
Package audit provides utilities for security event logging.
|
Package audit provides utilities for security event logging. |
|
|
|
|
|
|
Package handlers provides common HTTP handler utilities.
|
Package handlers provides common HTTP handler utilities. |
|
|
|
Package jwt issues and verifies EdDSA-signed JWTs.
|
Package jwt issues and verifies EdDSA-signed JWTs. |
jwttest
Package jwttest generates Ed25519 key material in the env wire format the jwt package reads, so tests in any package can build an issuer or verifier.
|
Package jwttest generates Ed25519 key material in the env wire format the jwt package reads, so tests in any package can build an issuer or verifier. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Package server provides HTTP server utilities with graceful shutdown support.
|
Package server provides HTTP server utilities with graceful shutdown support. |
Click to show internal directories.
Click to hide internal directories.