
Golang Dependency Injection
Go dependency injection guide covering manual constructor wiring and four DI library options compared.
- skills.sh installs
- 41.4K
- GitHub stars
- 3.9K
- last updated
- Aug 21, 2026
What it does
- Covers why DI matters, manual constructor injection, and a comparison of google/wire, uber-go/dig, uber-go/fx, and samber/do
- Includes a decision table scoring manual wiring and each library on type safety, codegen, reflection, lazy loading, singletons, scopes, and shutdown
- Enforces that dependencies come through constructors and that the container exists only at the composition root, never as an argument
- Designed for Go teams choosing between manual wiring below 10 services and a library for larger, interconnected service graphs
Install
$ npx -y skills add samber/cc-skills-golang --skill golang-dependency-injection -yInstalls into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.
Files
Persona: You are a Go software architect. You guide teams toward testable, loosely coupled designs — you choose the simplest DI approach that solves the problem, and you never over-engineer.
Orchestration mode: Fan out the three sub-agents described in Refactor mode (global/init discovery, concrete-dependency mapping, service-locator detection) when refactoring a large coupled codebase toward dependency injection, and consolidate into one migration plan. On Claude Code, use ultracode to opt into multi-agent orchestration explicitly.
Modes:
- Design mode (new project, new service, or adding a service to an existing DI setup): assess the existing dependency graph and lifecycle needs; recommend manual injection or a library from the decision table; then generate the wiring code.
- Refactor mode (existing coupled code): use up to 3 parallel sub-agents — Agent 1 identifies global variables and
init()service setup, Agent 2 maps concrete type dependencies that should become interfaces, Agent 3 locates service-locator anti-patterns (container passed as argument) — then consolidate findings and propose a migration plan.
Details
- Repository
- github.com/samber/cc-skills-golang
- Category
- Go
- First seen
- Apr 16, 2026
More from samber/cc-skills-golang
All 47- Golang Popular Libraries41.4K
- Golang Stretchr Testify41.3K
- Golang Continuous Integration41.3K
- Golang Grpc41.1K
- Golang Samber Lo40.4K
- Golang Stay Updated40.3K
- Golang Samber Do40.2K
- Golang Samber Slog40.1K
- Golang Samber Oops40K
- Golang Samber Mo40K
- Golang Samber Hot40K
- Golang Samber Ro39.9K
- Golang Spf13 Cobra39K
- Golang Swagger39K
- Golang Graphql38.8K
- Golang Google Wire38.7K
- Golang Spf13 Viper38.7K
- Golang Uber Fx38.4K
- Golang Uber Dig38.4K
- Golang How To38.3K
- Golang Linter26.5K
- Golang Pkg Go Dev13.7K
- Golang Refactoring13.3K
- Golang Gopls12.9K
Similar to Golang Dependency Injection
More Go
golang-samber-doSkillsamber/cc-skills-golang40.2K installsDependency injection toolkit for Go using samber/do, covering containers, scopes, lifecycle, and module organization.
golang-uber-digSkillsamber/cc-skills-golang38.4K installsReflection-based DI container for Go with Provide/Invoke, named values, value groups, and interface binding.
factoryPluginhmlongco/Factory2.9K starsIn-depth guide to Factory, a container-based DI system for Swift and SwiftUI.
go-genericsSkillcxuu/golang-skills1.1K installsConcrete guidance for deciding when Go generics pay off, with constraint and type-alias rules and common pitfalls.
go-interfacesSkillcxuu/golang-skills1.4K installsGo interfaces guidance for accepting interfaces, returning concrete types, and safe type assertions.