If you're looking for what comes after wire, take a look at kanna-di
For a long time, compile-time DI in Go meant google/wire. But wire is no longer taking new features, and every so often the question comes up: what do you use instead? This post introduces kanna-di , which I wrote to sit in that spot. Like wire, the generated code is plain Go and imports nothing at run time. The difference is that you register no providers . What was tedious Think about what you…
For a long time, compile-time Dependency Injection (DI) in Go meant the google/wire library. However, wire has ceased to accept new features, prompting the question of what alternative to use. This article introduces kanna-di, which fills that gap. Similar to wire, kanna-di generates code that is plain Go and does not import anything at runtime.
The key difference lies in how providers are registered. In wire, you declare the injector's signature yourself, use wire.NewSet to collect providers, and pass it to wire.Build and wire.Bind for every interface and constructor. With kanna-di, you simply mark the struct that will serve as the container, and that's it. It examines each field's type, locates the constructor next to that type, follows the constructor's parameters recursively, and writes a constructor that calls everything in order.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.