golang-google-wire

Implement compile-time dependency injection in Go using google/wire code generation.

1|Updated Feb 2, 2026
One-click install
npx skills add https://github.com/rockcookies/skills --skill golang-google-wire-rockcookies
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: golang-google-wire
Source: https://github.com/rockcookies/skills/tree/main/skills/samber-golang/golang-google-wire
Command: npx skills add https://github.com/rockcookies/skills --skill golang-google-wire-rockcookies

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires github.com/google/wire, and includes references (resource) components.

What problem does it solve? Manually wiring Go application dependencies is error-prone, and runtime DI containers hide misconfigurations until startup. This Skill guides you through google/wire so the dependency graph is resolved at compile time, with errors surfaced by wire ./... instead of at first request. ## Core Features & Use Cases - Provider Sets and Injectors: Organize constructors into per-package wire.NewSet groups and declare injectors with wire.Build behind the //go:build wireinject tag. - Interface Bindings and Struct Injection: Use wire.Bind, wire.Struct, wire.Value, wire.InterfaceValue, and wire.FieldsOf to map interfaces to concrete types and promote struct fields as graph nodes. - Cleanup Chains and Testing: Return (T, func(), error) from providers for reverse-order cleanup, and build test injectors that swap real providers for fakes. - Use Case: When your Go service grows and wire.Build accumulates dozens of providers, reorganize them into per-package sets like InfraSet, RepoSet, and ServiceSet, then regenerate wire_gen.go with wire ./.... ## Quick Start Ask the AI to set up google/wire dependency injection for your Go project with per-package provider sets and a wireinject-tagged injector.

Frequently Asked Questions about golang-google-wire

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up google/wire dependency injection in Go?▼

Install the wire CLI with go install github.com/google/wire/cmd/wire@latest, define providers as constructor functions, group them with wire.NewSet, and declare an injector calling wire.Build in a file tagged //go:build wireinject. Run wire ./... to generate wire_gen.go.

google/wire vs uber/fx: which DI framework for Go?▼

Wire resolves dependencies at compile time via code generation with no runtime container, while fx uses runtime reflection with lifecycle hooks like OnStart/OnStop and signal handling. Choose wire for simplicity and compile-time safety; choose fx for long-running daemons needing graceful shutdown.

Why does wire fail with 'no provider found' for my interface?▼

Wire never auto-resolves interface satisfaction; bindings must be explicit. Add wire.Bind(new(MyInterface), new(*MyImpl)) to the provider set so wire knows which concrete type satisfies the interface.

Why do I get 'redeclared in this block' after running wire?▼

The injector file is missing the //go:build wireinject build tag, so both the stub and the generated wire_gen.go define the same function. Add //go:build wireinject as the first line of the injector file.

How do I inject two values of the same type with google/wire?▼

Wire enforces one provider per type, so wrap the underlying type in distinct named types, such as type PrimaryDSN string and type ReplicaDSN string. Update the providers and consumers to use the named types.

Should I edit wire_gen.go to fix build errors?▼

Never edit wire_gen.go; it is overwritten on every wire ./... run. Fix the provider or injector source files, ensure all dependencies are provided in the graph, then regenerate with wire ./... or validate with wire check ./... .