golang-google-wire

Resolve compile-time dependency injection wiring in Go projects using google/wire.

2|Updated Mar 13, 2023
One-click install
npx skills add https://github.com/haipham22/golang-sample --skill golang-google-wire-haipham22
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-google-wire
Source: https://github.com/haipham22/golang-sample/tree/main/.agents/skills/golang-google-wire
Command: npx skills add https://github.com/haipham22/golang-sample --skill golang-google-wire-haipham22

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps you design and troubleshoot compile-time dependency injection in Go projects that use google/wire, so constructor graphs stay type-safe, readable, and easy to regenerate after changes.

Core Features & Use Cases

  • Provider set design: Organize constructors into reusable sets that keep large applications composable.
  • Interface bindings: Map interfaces to concrete implementations explicitly so dependency graphs resolve predictably.
  • Cleanup handling: Propagate shutdown logic through providers that return cleanup functions and errors.
  • Generated code workflow: Keep generated wiring in sync by rerunning code generation instead of editing generated output by hand.
  • Testing support: Build test-only injectors and fake bindings for integration tests without changing production wiring.

Quick Start

Use the golang-google-wire skill to review a Go repository, identify its wiring pattern, and explain the correct provider, binding, and regeneration steps needed to keep google/wire working.

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 compile-time dependency injection in Go using google/wire?

Compile-time dependency injection in Go uses google/wire to generate wiring code from provider sets and wire.Build graphs, ensuring type-safe constructor resolution without runtime reflection overhead.

How do I bind interfaces to concrete implementations with wire?

Interface bindings in wire map interfaces to concrete implementations explicitly using wire.Bind mappings, ensuring dependency graphs resolve predictably and type-safely during code generation.

What is the best way to organize providers for large Go applications with wire?

Organize constructors into reusable provider sets to keep large applications composable, allowing wire to resolve complex dependency graphs efficiently during code generation.

How do I handle cleanup functions in a google/wire dependency graph?

Cleanup handling in google/wire propagates shutdown logic through providers that return cleanup functions and errors, ensuring proper resource teardown when the dependency graph is torn down.

Can I use google/wire to build test injectors without affecting production wiring?

Yes, google/wire supports building test-only injectors and fake bindings for integration tests using wireinject build tags, keeping testing support isolated without changing production wiring.

Why does my google/wire generated code fail after adding a new provider?

Generated wiring fails when wire_gen.go is out of sync, requiring you to rerun code generation to regenerate the output instead of editing the generated file by hand.