golang-google-wire

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

Updated May 9, 2026
One-click install
npx skills add https://github.com/LuminaVault/LuminaVaultShared --skill golang-google-wire-luminavault
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: golang-google-wire
Source: https://github.com/LuminaVault/LuminaVaultShared/tree/main/.agents/skills/golang-google-wire
Command: npx skills add https://github.com/LuminaVault/LuminaVaultShared --skill golang-google-wire-luminavault

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 errors until startup. This Skill guides you through google/wire so the compiler catches missing dependencies and generates plain Go constructor calls with no runtime reflection. ## Core Features & Use Cases - Provider Sets and Injectors: Organize providers with wire.NewSet per package and declare injectors with wire.Build under the //go:build wireinject tag. - Interface Bindings and Struct Injection: Map interfaces to concrete types with wire.Bind, fill struct fields with wire.Struct, and promote config fields with wire.FieldsOf. - Cleanup Chains: Return (T, func(), error) from providers so wire generates reverse-order shutdown logic for databases, caches, and exporters. - Use Case: You are building an HTTP service with Postgres and Redis. Define per-package provider sets, write one injector, run wire ./..., and get a committed wire_gen.go that fails CI if the graph breaks. ## Quick Start Ask the AI to set up google/wire dependency injection for your Go service with per-package provider sets and a cleanup-aware 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 get github.com/google/wire/cmd/wire, define providers as functions returning (T, error) or (T, func(), error), 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 vs dig for Go dependency injection?▼

Wire resolves the graph at compile time and emits plain Go calls with no runtime container, while dig and fx use runtime reflection. Choose wire for compile-time safety; choose fx when you need lifecycle hooks like OnStart/OnStop and signal handling.

Why does wire report no provider found for my interface?▼

Wire never auto-resolves interface satisfaction, so you must declare bindings explicitly. Add wire.Bind(new(MyInterface), new(*MyImpl)) to the provider set so the graph 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 wire_gen.go define the same function. Add the tag as the first line of the injector file so only the generated file compiles.

How do I inject two values of the same type with 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 a build error?▼

Never edit wire_gen.go because it is overwritten on every wire run. Fix the provider or injector source, ensure new dependencies are provided in a set, and re-run wire ./... to regenerate it.