Dependency Injection is a language-agnostic approach to building well designed and testable code. In many dynamically typed languages, dependency injection can easily be automated to provide a platform for rapid application development, but runtime automatic dependency injection has it’s drawbacks. Go makes automatic DI more of a challenge; powerful languages require powerful tooling and Go is no exception.
In this talk we will explore some novel (read: extremely hacky) approaches to automatic dependency injection, from traversing the AST and the challenges and magic of runtime DI with a custom solution through to generating factories for compile-time DI with google’s wire library and beyond.