$ show go-kod/kod
This repository provides a generic-based dependency injection framework for Go, called 'kod' (Killer Of Dependency), along with a CLI tool for code generation, component registration, and dependency graph validation. It features a rich interceptor chain for cross-cutting concerns (retry, validation, tracing, rate limiting, circuit breakers, etc.), and includes a comprehensive test suite and examples. The codebase also incorporates an extensive set of AI agent skills for software development workflows (grilling, code review, TDD, domain modeling) from the mattpocock/skills ecosystem. The primary value is the DI framework that leverages Go generics to provide compile-time safety for component wiring, with generated boilerplate code. The architecture is modular with clear separation of core, interceptors, internal utilities, and tests. It is actively maintained with modern Go features.
The LLM identified 4 files worth highlighting for reuse:
Defines the core interceptor interface and a chain builder for composing middleware. Includes conditional combinators (If, And, Or, Not, IsMethod) that allow fine-grained control over interceptor application. This pattern is self-contained (only depends on standard library and a simple Method type) and can be extracted for use in any Go server or RPC framework requiring a flexible middleware pipeline.
Provides a generic, thread-safe singleton factory using sync.Mutex and lazy initialization. The implementation is minimal and correct, handling double-checked locking and reset functionality. It can be extracted and reused anywhere a single instance of a type needs to be managed across goroutines.
Implements a sliding window data structure for counting events over time, using a ring buffer of buckets. Supports time-based and point-based window policies. This is a foundational component for rate limiting and metrics aggregation, and can be extracted for other projects needing rolling window calculations.
A state-machine implementation of the circuit breaker pattern with Closed/Open/HalfOpen states, failure counting, and automatic recovery. Uses a rolling window to track recent failures. The logic is self-contained (depends only on the rolling package) and can be extracted for resilience in any Go service.