
Golang Google Wire
Wire up Google Wire dependency injection in Go without wireinject build-tag mistakes or broken provider sets.
Overview
golang-google-wire is an agent skill for the Build phase that fixes and standardizes Google Wire injectors, provider sets, and wireinject build tags in Go backends.
Install
npx skills add https://github.com/samber/cc-skills-golang --skill golang-google-wireWhat is this skill?
- Requires //go:build wireinject on injector files so stubs do not collide with wire_gen.go at go build
- Explains wire_gen.go is the compiled entry while the tagged stub is wire-only
- Covers wire.Build with provider sets (InfraSet, ServiceSet) and app constructors
- Interface binding and provider-set patterns for testable Go services
- Steers away from renaming InitApp or deleting wire_gen.go as bogus fixes for redeclared errors
Adoption & trust: 1.8k installs on skills.sh; 2k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
Wire runs clean but go build dies on duplicate InitApp because your injector stub compiles alongside wire_gen.go.
Who is it for?
Indie Go developers adopting Wire for the first time or refactoring manual constructors into provider sets.
Skip if: Projects using pure fx/dig, tiny scripts with no DI, or teams that do not use google/wire at all.
When should I use this skill?
Setting up or debugging google/wire injectors, wire_gen.go conflicts, or provider/interface bindings in a Go project.
What do I get? / Deliverables
Your injector uses wireinject tagging and sound provider bindings so wire generate and go build both succeed with a single compiled InitApp.
- Corrected injector file with wireinject build constraint
- Provider set layout guidance for wire.Build graphs
Recommended Skills
Journey fit
How it compares
Procedural Wire expertise—not a runtime DI framework installer or a generic Go linter skill.
Common Questions / FAQ
Who is golang-google-wire for?
Solo builders and small teams writing Go backends who chose google/wire and need agent guidance on injectors, tags, and provider sets.
When should I use golang-google-wire?
During Build/backend work when setting up InitApp injectors, fixing redeclared symbol errors after wire, or designing interface bindings in Wire sets.
Is golang-google-wire safe to install?
It is documentation-style procedural knowledge; review the Security Audits panel on this page and treat suggestions like any code change—run tests and wire after edits.
SKILL.md
READMESKILL.md - Golang Google Wire
[ { "id": 1, "name": "build-constraint-on-injector", "description": "Tests that the model adds //go:build wireinject to injector files to prevent duplicate-symbol compile errors", "prompt": "I'm setting up google/wire in my Go project. Here's my injector file:\n\n```go\npackage main\n\nimport \"github.com/google/wire\"\n\nfunc InitApp() (*App, error) {\n wire.Build(InfraSet, ServiceSet, NewApp)\n return nil, nil\n}\n```\n\nWire generates wire_gen.go successfully, but when I run `go build`, I get a 'redeclared in this block' compile error for InitApp. What's wrong and how do I fix it?", "trap": "Without the skill, the model may suggest renaming the function, reorganizing packages, or not identify that the missing //go:build wireinject tag is the cause — both the stub and wire_gen.go define InitApp, causing the duplicate.", "assertions": [ {"id": "1.1", "text": "Identifies the missing //go:build wireinject build tag as the root cause"}, {"id": "1.2", "text": "Shows //go:build wireinject as the first line of the injector file"}, {"id": "1.3", "text": "Explains that the tag prevents the stub from being compiled into the binary (only wire_gen.go compiles)"}, {"id": "1.4", "text": "Does NOT suggest renaming the function or reorganizing packages as the fix"}, {"id": "1.5", "text": "Does NOT suggest deleting wire_gen.go as the fix"} ] }, { "id": 2, "name": "interface-binding-required", "description": "Tests that wire.Bind is required for interface-to-concrete mappings and cannot be inferred", "prompt": "I have this Go code using google/wire:\n\n```go\n// repo.go\ntype UserStore interface {\n GetUser(id int64) (*User, error)\n}\n\ntype PostgresUserRepo struct{ db *sql.DB }\nfunc (r *PostgresUserRepo) GetUser(id int64) (*User, error) { ... }\nfunc NewUserRepo(db *sql.DB) *PostgresUserRepo { return &PostgresUserRepo{db: db} }\n\n// service.go\nfunc NewUserService(store UserStore) *UserService { return &UserService{store: store} }\n\n// wire_providers.go\nvar AppSet = wire.NewSet(NewDB, NewUserRepo, NewUserService)\n```\n\nWhen I run `wire ./...` I get: `no provider found for UserStore`. NewUserRepo returns *PostgresUserRepo which clearly implements UserStore. Why doesn't wire figure this out?", "trap": "Without the skill, the model might suggest wire should automatically resolve the interface, or suggest wrapping NewUserRepo to return UserStore directly, missing the explicit wire.Bind requirement.", "assertions": [ {"id": "2.1", "text": "Explains that wire never auto-resolves interface satisfaction — bindings must be explicit"}, {"id": "2.2", "text": "Shows wire.Bind(new(UserStore), new(*PostgresUserRepo)) added to the provider set"}, {"id": "2.3", "text": "Places wire.Bind inside the same wire.NewSet (or adds it to a set in wire.Build)"}, {"id": "2.4", "text": "Explains WHY wire requires explicit bindings (predictability — avoids surprise rebinding when new implementations are added)"}, {"id": "2.5", "text": "Does NOT suggest changing NewUserRepo to return UserStore directly as the primary fix"} ] }, { "id": 3, "name": "duplicate-type-named-wrapper", "description": "Tests the named-type pattern to disambiguate multiple values of the same underlying type", "prompt": "I'm building a Go service with google/wire. I need to inject two database connection strings — one for the primary database and one for a read replica. I tried this:\n\n```go\nfunc NewPrimaryDSN() string { return os.Getenv(\"PRIMARY_DSN\") }\nfunc NewReplicaDSN() string { return os.Getenv(\"REPLICA_DSN\") }\n\nvar DBSet = wire.NewSet(NewPrimaryDSN, NewReplicaDSN, NewPrimaryDB, NewReplicaDB)\n```\n\nWire complains about multiple bindings for string. How should I structure this?", "trap": "Without the skill, the model might suggest using wire.Value or provider arguments, or use a config struct — missing the idiomatic named-t