Documentation
¶
Overview ¶
Package kit provides essential infrastructure components for Go API development.
go-kit is a collection of reusable packages for building production-ready Go applications. It includes error handling, configuration management, logging, middleware, and database connectivity.
Core Packages ¶
- code: Error code framework with HTTP status mapping
- config: Configuration loading with hot-reload support
- log: Structured logging with multiple sinks
- resp: Unified API response formatting
- middleware: Echo middleware (JWT, Casbin, CORS, Recovery)
- db: Database connection management (MySQL, Redis, MongoDB, Kafka)
- health: Component health checking
- cache: Redis cache abstraction
- metrics: Prometheus metrics collection
- utils: Common utilities
- validator: Custom validation extensions
- fx: Uber Fx module integrations
Quick Start ¶
import (
"github.com/NSObjects/go-kit/code"
"github.com/NSObjects/go-kit/config"
"github.com/NSObjects/go-kit/log"
)
func main() {
cfg := config.Load("config.yaml")
logger := log.New(cfg.Log)
if err := doSomething(); err != nil {
return code.WrapDatabaseError(err, "operation failed")
}
}
Version ¶
v1.0.0 - Stable release
Directories
¶
| Path | Synopsis |
|---|---|
|
Package cache provides Redis cache abstraction.
|
Package cache provides Redis cache abstraction. |
|
Package code provides business error codes with HTTP status mapping.
|
Package code provides business error codes with HTTP status mapping. |
|
Package config provides configuration management with hot-reload support.
|
Package config provides configuration management with hot-reload support. |
|
Package db provides database connection management.
|
Package db provides database connection management. |
|
Package errors provides error handling primitives for Go 1.21+.
|
Package errors provides error handling primitives for Go 1.21+. |
|
Package health provides component health checking.
|
Package health provides component health checking. |
|
Package log provides structured logging with multiple sink support.
|
Package log provides structured logging with multiple sink support. |
|
Package metrics provides Prometheus metrics collection.
|
Package metrics provides Prometheus metrics collection. |
|
Package middleware provides Echo middleware implementations.
|
Package middleware provides Echo middleware implementations. |
|
Package resp provides unified API response formatting.
|
Package resp provides unified API response formatting. |
|
Package utils provides common utility functions.
|
Package utils provides common utility functions. |
|
Package validator provides custom validation extensions.
|
Package validator provides custom validation extensions. |
Click to show internal directories.
Click to hide internal directories.