Last Updated: May 22, 2026
Dependency injection is the practice of handing a piece of code the things it needs from the outside instead of letting it construct them itself. In Go this rarely involves a framework. A constructor takes interfaces as parameters, main() wires the real implementations together, and tests pass fakes in. This chapter walks through the idiomatic pattern, the interface conventions that make it click, where the wiring lives, and when (if ever) to use wire or fx.