kanna-di: A Compile-Time Go DI Tool as a Successor to google/wire
Google's wire is no longer accepting new features, leaving Go developers looking for an alternative for compile-time dependency injection. The author introduces kanna-di, which generates plain Go code without runtime imports, like wire. Unlike wire, it requires no provider registration: developers mark a container struct with a //kanna:container annotation, and the tool infers constructors from each field's type and resolves their parameters recursively. Interface implementations are specified with a di:"with=..." tag, and any non-injectable setup, such as opening a database, is written by hand in the composition root. Running go generate then produces a di_gen.go file containing a newServer function that wires all dependencies together.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in