go-common

module
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 24, 2026 License: MIT

README

Go Common

CI Go Report Card codecov CodeRabbit

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 Local JWT validation and generation
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
utils Common utility functions
queue RabbitMQ pub/sub with reconnection, retries, and DLQ
health Dependency health checking

Quick Start

import (
    "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
cfg := config.NewServiceConfig("8080")
dbCfg := config.NewDatabaseConfig()

// Database
db, _ := database.Connect(dbCfg)
defer database.CloseDB(db)

// Auth middleware
jwtService, _ := jwt.NewValidatorOnly(cfg.JWTSecret)
authMiddleware := middleware.NewAuthMiddleware(jwtService)

// 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

Version

Current version: v1.0.0

See CHANGELOG.md for breaking changes and migration guides.

License

MIT

Directories

Path Synopsis
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 provides JWT token generation and validation for portfolio services.
Package jwt provides JWT token generation and validation for portfolio services.
Package renderer provides email template rendering for all services.
Package renderer provides email template rendering for all services.
Package server provides HTTP server utilities with graceful shutdown support.
Package server provides HTTP server utilities with graceful shutdown support.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL