DEV Community

Aleksei Aleinikov
Aleksei Aleinikov

Posted on

đź§© Two DI Examples in Go That Click in 2025

Tired of “magical” dependency injection frameworks?

In 2025 my rule is simple: be explicit.
A component shouldn’t create what it needs — it should receive it.

Why this matters:
🔍 Clarity — your call order is the dependency graph
🧪 Testability — swap real DBs for in-memory fakes in seconds
⚡ Tooling works — autocomplete & static checks stay reliable
🚫 No hidden surprises — errors show up right where deps are wired

👉 I show two Go examples: one with the hidden anti-pattern and one with clean, explicit DI you can drop into production today.
https://levelup.gitconnected.com/two-di-examples-in-go-that-click-in-2025-a7599c81dea9

Top comments (0)