golang-google-wire

Implements compile-time dependency injection for Go services and CLIs using google/wire templates.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps you set up compile-time dependency injection in Go so your application graph is validated by the compiler and generated into fast, plain Go constructors.

Core Features & Use Cases

  • Provider-based wiring: Define dependency constructors as provider functions and compose them into a complete object graph.
  • Reusable provider sets: Use wire.NewSet to group providers and share them across injectors with predictable inputs/outputs.
  • Explicit interface bindings: Use wire.Bind to map interfaces to concrete implementations without relying on runtime reflection.
  • Structured injection helpers: Use wire.Struct, wire.Value, wire.InterfaceValue, and wire.FieldsOf to inject named fields, constants, and interface literals cleanly.
  • Cleanup chain support: Return (T, func(), error) so generated code executes cleanup functions in reverse construction order.

Quick Start

Run wire ./... in your module after updating your injector providers and ensure every injector file includes the //go:build wireinject build tag.

Frequently Asked Questions about golang-google-wire

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

FAQPage Schema
What is compile-time dependency injection in Go and how does it work?

Compile-time dependency injection in Go validates your application's object graph at build time rather than runtime. It generates plain Go constructors by analyzing provider functions, ensuring the graph is completely type-safe.

How do I bind an interface to a concrete implementation in Go dependency injection?

To bind an interface to a concrete implementation, use wire.Bind in your provider set. This maps interfaces directly to concrete implementations without relying on runtime reflection.

How do I run cleanup functions in a generated Go dependency injection graph?

To run cleanup functions, have your providers return the (T, func(), error) pattern. The generated code executes these cleanup functions in reverse construction order to manage lifecycle teardown.

Does compile-time dependency injection work with Go services and CLIs?

Compile-time dependency injection works for building Go services and CLIs. You define structured providers, interface bindings, constants, and struct field injection to create a valid application initialization graph.

How do I regenerate the Go dependency injection code after updating providers?

To regenerate the dependency injection code, run wire ./... in your module after updating injector providers. Ensure injector files include the //go:build wireinject build tag and commit the wire_gen.go output.

What's the best way to group and share Go providers across multiple injectors?

The best way to group and share providers is using wire.NewSet. This creates reusable provider sets with predictable inputs and outputs that can be composed across multiple injectors via wire.Build.