What problem does it solve?
It prevents tightly coupled Go code by ensuring dependencies are passed explicitly, which improves testability, maintainability, and predictable lifecycle management.
Core Features & Use Cases
- Constructor-based DI: Prefer manual constructor injection for small projects and inject dependencies instead of using globals or init().
- Interface-first design: Define interfaces at the consumption site to decouple services from concrete implementations.
- Correct DI container usage: Keep the container/composition root at app startup only, avoid passing the injector into services, and use lazy creation with singletons for stateful services.
- DI library decision support: Select among google/wire, uber-go/dig + fx, and samber/do based on project size, lifecycle needs, and type-safety constraints.
- Testing patterns: Mock at the interface boundary and, when using samber/do, clone and override providers for isolated tests.
Quick Start
Ask the AI to refactor your Go service wiring to use constructor injection (no globals or init()), define interfaces at the consumer boundary, and generate the recommended DI wiring code for either manual injection or a DI library (based on your number of services and lifecycle needs).