Google Wire Is Dead and Uber Fx Panics at Boot — A Compile-Time DI Library Steps In
Dependency injection in Go has been split between compile-time safety that's painful to use and runtime convenience that fails in production. A library that delivers both — and whose generated code doesn't tether you to a framework — removes the trade-off entirely.
Google Wire's compile-time dependency injection came with three persistent headaches: mandatory `return nil, nil` dummy statements, no startup hooks, and zero generics support. Uber Fx swaps those for a clean API but relies on runtime reflection, so missing dependencies and type mismatches only surface as panics when the binary starts — a time bomb that gets worse as projects grow. A new library, dig, generates pure Go code at compile time with no reflection overhead, supports native generics, provides built-in Invoke hooks, and catches closure capture mistakes that Wire silently ignores. Its API mirrors Fx closely enough that migration takes minutes, and the generated output carries no runtime dependency on dig itself.
Wire's `return nil, nil` pattern is a symptom of treating code generation as a side effect rather than a first-class output; dig eliminates it by returning a real function from `Build`.
Runtime DI frameworks shift failure from the compiler to the deploy, which is the worst possible moment to discover a missing dependency.
Compile-time code generation that produces plain Go functions sidesteps both the reflection tax and the lock-in of a runtime container.
Closure capture mistakes are a subtle class of bug that Wire ignores entirely; catching them at generation time prevents silent miscompilation.
The Go community's tolerance for `return nil, nil` for years suggests a willingness to accept awkward tooling when the alternative (runtime panics) feels worse.