Lazy Providers in Dig

from blog software is fun, | ↗ original
If you haven’t yet read my previous post on depedency injection in Go, please do so first. This post describes a simple technique to make dig’s DI container even more powerful. All values provided by dig’s container are singletons. The provider is called the first time the value is required and the result is cached. All subsequent providers that...