3 ms·
Why is Go anti dependency injection? Accept side interfaces seems to be compatible with DI. Just maybe not with the registration/automatic injection. But I'm
by aleksiy123 3y ago
Why is Go anti dependency injection?
Accept side interfaces seems to be compatible with DI.
Just maybe not with the registration/automatic injection.
But I'm not too familiar with go idioms.
- t8sr 3y agoI probably over-stated that a bit. I don't think there's a hard stance against it. I do think it's rarely a good way to structure your program, because it makes it harder to know what's happening, and the goal should be to make it easier to see what's happening, both for the programmer and the poor devops guy who has to debug it when it goes down in production and people are yelling. Of course the real world is complicated, and DI isn't always avoidable. You are right that Go's accept-side interfaces are neutral w.r. to DI.