What problem does it solve?
This Skill helps you implement reliable dependency injection in Go using samber/do, avoiding tangled constructor wiring and reducing startup/runtime failures from hidden dependency issues.
Core Features & Use Cases
- Service container with lifecycles: Register services as lazy (default), eager, transient, or pre-created values for the right creation timing.
- Provider-based registrations: Use provider functions that return (service, error) so dependency failures are handled immediately and explicitly.
- Composition-root organization: Keep container access confined to startup/composition root, while business code depends on interfaces.
- Scopes and lifecycle management: Use scopes for module separation and implement health checks and graceful shutdown for managed services.
- Operational patterns: Prefer implicit aliasing via InvokeAs, support named services, and use struct tag injection to reduce repetitive MustInvoke calls.
Quick Start
Register your dependencies at the composition root with do.New and do.Provide/do.ProvideValue, then resolve them with do.MustInvoke or InvokeAs where appropriate.