golang-dependency-injection
golang dependency injection
What it does
- You have 15+ services with cross-dependencies
- You need lifecycle management (health checks, graceful shutdown)
- You want lazy initialization or scoped containers
- Wiring order becomes fragile and hard to maintain
- google/wire examples — Compile-time code generation
- uber-go/dig + fx examples — Reflection-based framework
- samber/do examples — Generics-based, no code generation
Requirements & configuration
- | Testing requires real databases, APIs | Pass mock implementations in tests |
- You need lifecycle management (health checks, graceful shutdown)
- Container cloning creates an isolated copy where you override only the services you need to mock:
- This is particularly useful for integration tests where you want most services to be real but need to mock a specific boundary (database, external API, mailer).
- | Need health checks, graceful shutdown | Use a library with built-in lifecycle support |
Derived from the skill's own SKILL.md documentation · extracted 2026-07-23
golang-dependency-injection FAQ
What does the golang-dependency-injection skill do?
Comprehensive guide for dependency injection (DI) in Golang. Covers why DI matters (testability, loose coupling, separation of concerns, lifecycle management), manual constructor injection, and DI library comparison (google/wire, uber-go/dig, uber-go/fx, samber/do). Use this skill when designing service architecture, setting up dependency injection, refactoring tightly coupled code, managing singletons or service factories, or when the user asks about inversion of control, service containers, or wiring dependencies in Go. For a specific DI library, → See `samber/cc-skills-golang@golang-google-wire`, `samber/cc-skills-golang@golang-uber-dig`, `samber/cc-skills-golang@golang-uber-fx`, or `samber/cc-skills-golang@golang-samber-do` skills. You have 15+ services with cross-dependencies You need lifecycle management (health checks, graceful shutdown)
What does golang-dependency-injection require?
| Testing requires real databases, APIs | Pass mock implementations in tests | You need lifecycle management (health checks, graceful shutdown) Container cloning creates an isolated copy where you override only the services you need to mock: This is particularly useful for integration tests where you want most services to be real but need to mock a specific boundary (database, external API, mailer). | Need health checks, graceful shutdown | Use a library with built-in lifecycle support |
How do I install golang-dependency-injection?
Run: npx -y skills add https://github.com/samber/cc-skills-golang --skill golang-dependency-injection --agent claude-code — the source lives at github.com/samber/cc-skills-golang.
Maintain golang-dependency-injection?
Let people know it's listed here — add the badge (live metrics, light/dark aware) or a plain link to your README or docs.
[](https://getagentictools.com/skills/samber-cc-skills-golang-golang-dependency-injection?ref=badge) npx agentictools info skills/samber-cc-skills-golang-golang-dependency-injection The second line is the CLI lookup for this page — handy in READMEs and docs.