explaingit

google/wire

14,386GoAudience · developerComplexity · 3/5Setup · moderate

TLDR

Google's code generation tool for Go that reads how your program's components depend on each other and writes the boilerplate startup wiring code automatically.

Mindmap

mindmap
  root((Wire))
    What it does
      Dependency injection
      Code generation for Go
      Wires components at startup
    How it works
      Define provider functions
      Wire reads declarations
      Generates plain Go code
    Benefits
      No runtime reflection
      Readable output code
      Easy to test
    Status
      Feature complete
      Not actively maintained
      Fork to extend
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Eliminate hand-written dependency injection boilerplate in a Go application by letting Wire generate the startup wiring code from your provider declarations.

USE CASE 2

Make a Go application easier to test by having Wire produce explicit, readable connection code instead of relying on runtime reflection.

USE CASE 3

Understand the dependency graph of an existing Go project clearly because Wire's output is plain, readable Go code.

Tech stack

Go

Getting it running

Difficulty · moderate Time to first run · 1h+

Feature-complete and no longer actively maintained, install the wire CLI separately and run it as a code-generation step in your build process.

In plain English

Wire is a code generation tool for the Go programming language, created by Google, that solves a common problem in software development called dependency injection. Dependency injection is a technique where the pieces of a program are wired together explicitly, so each component receives the other components it needs rather than creating them itself or reaching for shared global variables. This makes programs easier to test and reason about, because the connections between parts are visible and explicit. The main job of Wire is to automate the repetitive work of writing that wiring code. You describe which components depend on which others, and Wire reads those descriptions and generates the Go code that sets everything up in the correct order at startup. Because Wire produces plain Go code, you can read and understand what it generates without any special tools, and it works without any runtime overhead or use of reflection (a technique where a program inspects its own structure at run time, which can be slower and harder to debug). Wire is considered feature-complete, meaning the core functionality is done and no new features are being added. The project's own README notes that it is no longer actively maintained, and users who want to extend it are directed to create their own fork (a personal copy of the project that they control). Bug reports and fixes were still accepted as of the last update, but new feature requests were not. The project is written in Go and is distributed as a command-line tool. Documentation including a tutorial, a user guide, and a best practices document are included in the repository. Community questions can be asked through GitHub Discussions.

Copy-paste prompts

Prompt 1
I have a Go web server with a database connection, a repository layer, and HTTP handlers. Show me how to define Wire providers and generate the wiring code.
Prompt 2
How do I set up Wire in a Go project from scratch? Walk me through creating provider functions, a wire set, and running the wire command.
Prompt 3
My Go application has two implementations of an interface (real database and a mock). How do I use Wire to switch between them for testing vs production?
Open on GitHub → Explain another repo

← google on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.