
golang-dependency-injection
Comprehensive guide for dependency injection (DI) in Golang
by samberFree
Description
golang-dependency-injection is an agent skill from the samber cc-skills-golang collection for dependency injection in Go. It explains why injection matters, for testability, loose coupling, separation of concerns and lifecycle management, and it helps an agent choose the simplest approach that solves the problem. Its persona is a Go software architect who guides teams to testable designs and never over-engineers. The skill has two modes. Design mode applies to a new project, a new service or a new service added to an existing setup: the agent assesses the dependency graph and lifecycle needs, recommends manual injection or a library from a decision table, and then generates the wiring code. Refactor mode applies to existing coupled code, and it runs up to three parallel sub-agents: one finds global variables and service set-up in init functions, one maps concrete types that should become interfaces, and one finds service-locator anti-patterns, where a container is passed around as an argument. The results are merged into one migration plan. The skill names libraries including google wire, uber dig and fx, and samber do, and it notes that their current APIs should be checked in their official documentation. It is useful for teams that have grown a Go codebase with global state and want a path to injection that keeps testing simple. It is listed on skills.sh, where the page shows install counts and GitHub stars for the collection, and its security audits all pass. Install it with npx skills add https://github.com/samber/cc-skills-golang --skill golang-dependency-injection.…
Highlights
- Design and refactor modes
- Manual injection or library choice
- Global state and init() discovery
- Service-locator detection
- Wiring code generation
- Installs from skills.sh
Ratings & Reviews
No ratings yet
Be the first to rate golang-dependency-injection.
People also visit
golang-dependency-injection FAQ
What does this skill cover?
Dependency injection in Go, including when to use manual injection and which libraries to consider.
Which libraries does it mention?
google wire, uber dig and fx, and samber do, with a note to check their current documentation.
What does refactor mode do?
It finds global variables, init-time service setup, concrete dependencies and service-locator patterns, then proposes a migration plan.
How do I install it?
Run npx skills add https://github.com/samber/cc-skills-golang --skill golang-dependency-injection.
What are the security audit results?
skills.sh lists three audits: Gen Agent Trust Hub Pass, Socket Pass and Snyk Pass.
How popular is it?
The page shows about 37.8K installs, and the cc-skills-golang repository has 3.5K GitHub stars.
What are the best golang-dependency-injection alternatives?
Popular alternatives to golang-dependency-injection include golang-design-patterns, golang-project-layout and golang-samber-do. See all golang-dependency-injection alternatives


