
Golang Uber Dig
Wire Go services with uber-go/dig using parameter objects, value groups, and container-friendly constructor patterns.
Overview
golang-uber-dig is an agent skill for the Build phase that teaches uber-go/dig dependency injection patterns including dig.In parameter objects and value groups for Go backends.
Install
npx skills add https://github.com/samber/cc-skills-golang --skill golang-uber-digWhat is this skill?
- Parameter-object pattern: embed dig.In so the container fills many deps via one constructor arg
- Value groups for contributing multiple handlers into one slice consumed by NewRouter
- Avoids unwieldy NewServer(logger, db, redis, config, metrics) signatures
- Steers away from plain structs without dig.In that the container cannot inject
- Emphasizes one-line dependency additions when using dig.In structs
Adoption & trust: 1.9k installs on skills.sh; 2k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
Your Go dig container has constructors with too many parameters or many handlers that must aggregate without manual registration glue.
Who is it for?
Solo Go backend devs adopting uber-go/dig for HTTP services with growing dependency graphs.
Skip if: Projects using wire/fx only, tiny scripts with no DI container, or teams not using uber-go/dig at all.
When should I use this skill?
User asks how to wire Go with uber-go/dig, parameter objects for many deps, or value groups for handlers and routers.
What do I get? / Deliverables
You refactor providers to dig.In parameter structs and value groups so the container injects dependencies and handler slices maintainably.
- dig.In parameter struct patterns
- Value group registration for multi-handler routers
- Refactored constructor signatures
Recommended Skills
Journey fit
How it compares
Dig-specific wiring guidance—not generic Go interface design or a full application bootstrap template.
Common Questions / FAQ
Who is golang-uber-dig for?
Indie Go developers wiring services with uber-go/dig who hit constructor sprawl or multi-handler router registration problems.
When should I use golang-uber-dig?
During Build backend work when designing NewServer/NewRouter providers, adding handlers, or cleaning up dig container modules.
Is golang-uber-dig safe to install?
It is procedural DI guidance only—check the Security Audits panel on this Prism page for the parent repo before installing the skill bundle.
SKILL.md
READMESKILL.md - Golang Uber Dig
[ { "id": 1, "name": "param-objects-many-deps", "description": "Tests use of dig.In parameter objects when a constructor has many dependencies", "prompt": "I'm wiring a Go service with uber-go/dig. I have a NewServer constructor that needs *zap.Logger, *sql.DB, *redis.Client, *Config, and *MetricsRegistry. The signature is getting unwieldy. How should I clean it up?", "trap": "Without the skill, the model keeps the long signature or wraps args in an ad-hoc struct without dig.In, missing the parameter-object pattern that lets the container fill the fields.", "assertions": [ {"id": "1.1", "text": "Embeds dig.In in the parameter struct"}, {"id": "1.2", "text": "Constructor takes the params struct as a single argument"}, {"id": "1.3", "text": "Does NOT just keep the long parameter list as the answer"}, {"id": "1.4", "text": "Does NOT use a plain struct without dig.In (which would not be filled by the container)"}, {"id": "1.5", "text": "Mentions readability/maintainability benefit (adding a new dep is a one-line change)"} ] }, { "id": 2, "name": "value-groups-for-handlers", "description": "Tests value groups when many constructors must contribute to one slice", "prompt": "In my Go HTTP server wired with uber-go/dig, I have several constructors (NewUserHandler, NewPostHandler, NewHealthHandler) and a NewRouter that should consume all of them. Each handler is registered independently. How do I wire this without the router knowing which handlers exist?", "trap": "Without the skill, the model invokes each handler individually inside main() and passes a slice to NewRouter, missing the group:\"...\" tag that decouples producers from consumers.", "assertions": [ {"id": "2.1", "text": "Each handler constructor returns a dig.Out struct (or uses dig.Group via Provide option) tagged with group:\"routes\" (or similar group name)"}, {"id": "2.2", "text": "NewRouter consumes a dig.In with a slice field tagged group:\"routes\""}, {"id": "2.3", "text": "Handlers are added with c.Provide — no manual slice assembly in main()"}, {"id": "2.4", "text": "Does NOT manually assemble the handler slice and pass it to NewRouter"}, {"id": "2.5", "text": "Mentions that group order is not guaranteed (or is silent on it; does NOT claim a specific order is guaranteed)"} ] }, { "id": 3, "name": "named-values-multiple-dbs", "description": "Tests dig.Name for multiple instances of the same type", "prompt": "My Go app needs two *sql.DB connections — one to the primary write database and one to a read replica. Both use the same *sql.DB type. Show me how to register and consume them with uber-go/dig.", "trap": "Without the skill, the model wraps the two connections in different types (struct PrimaryDB / struct ReadOnlyDB) instead of using dig.Name on a single type.", "assertions": [ {"id": "3.1", "text": "Uses dig.Name(\"...\") on c.Provide for at least one of the two databases (or uses dig.Out result tags name:\"...\")"}, {"id": "3.2", "text": "Both providers register the same *sql.DB type, distinguished by name"}, {"id": "3.3", "text": "Consumer uses dig.In with name:\"primary\" / name:\"readonly\" tags"}, {"id": "3.4", "text": "Does NOT introduce wrapper types like type PrimaryDB *sql.DB just to disambiguate"}, {"id": "3.5", "text": "Does NOT register both as plain *sql.DB without names (which dig rejects at Provide time)"} ] }, { "id": 4, "name": "as-to-hide-concrete", "description": "Tests dig.As to expose only an interface to consumers", "prompt": "I have a *PostgresDB concrete struct in my Go code that has many internal fields and methods. I want consumers to depend only on a Database interface (Query, Exec). How do I register it with uber-go/dig so consumers can never accidentally see the concrete type?", "trap": "Without the skill, the model registers the