golang-google-wire

Generate compile-time dependency injection wiring for Go applications using google/wire.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires go, wire, and includes references (resource) components.

What problem does it solve?

This Skill eliminates runtime dependency injection ambiguity by generating compile-time wiring code, so missing providers and invalid bindings are caught when you run wire rather than during application startup or first request.

Core Features & Use Cases

  • Compile-time dependency injection using google/wire so constructors become plain Go calls via generated wire_gen.go.
  • Provider graph building with wire.NewSet, wire.Build, and injector functions using the wireinject build tag.
  • Explicit interface bindings and value wiring through wire.Bind, wire.Value, wire.InterfaceValue, wire.Struct, and wire.FieldsOf for precise graph resolution.
  • Use Case: If your Go service has a Postgres DB pool, Redis client, repositories, and services, this Skill helps you structure provider sets and generate an application injector that wires everything consistently with cleanup chaining.

Quick Start

Use the golang-google-wire skill to set up your injector with //go:build wireinject and then run wire ./... to regenerate wire_gen.go after you change your provider graph.

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 to avoid runtime errors?

Compile-time dependency injection in Go uses google/wire to generate wiring code via wire_gen.go, catching missing providers and invalid bindings when you run the wire command rather than during application startup.

What is the best way to wire multiple service providers and repositories in a Go application?

The best way to wire Go service providers and repositories is using wire.NewSet to group provider functions and wire.Build to construct an injector, ensuring consistent dependency graph resolution across multiple packages.

How do I bind interfaces to concrete implementations using google/wire?

Binding interfaces in google/wire uses wire.Bind to map an interface to a concrete implementation, while wire.Value, wire.Struct, and wire.FieldsOf handle explicit value and structured field injection for precise graph resolution.

Do I need to commit the generated wire_gen.go file to my repository?

Yes, you must commit wire_gen.go to your repository after running wire ./... to regenerate code, ensuring the dependency graph and cleanup semantics are satisfied for the build.

Why do I need the wireinject build tag in my Go injector functions?

The wireinject build tag marks injector functions for code generation, allowing the wire tool to parse provider sets and generate the concrete wire_gen.go file while excluding the injector stub from the final build.

Does google/wire support cleanup chaining for resources like database pools?

Yes, google/wire supports cleanup chaining for resources like Postgres DB pools and Redis clients, allowing providers to return cleanup functions that the generated injector executes during application shutdown.

Related Skills