A quick and dirty library that adds things that I've felt in the past are missing from Uber's dig dependency library.
One big thing dig is missing is an interface that's the same for Scope and Container - this makes it harder to use
interchangeably, so this package uses an interface for the Container type instead of just a struct.
While Go's error returns are amazing, it does get a bit cumbersome to handle errors when you're registering many constructors and invoking them.
This package provides a Must* for the usual functions, making it simpler to register items if you don't mind throwing
fatal errors when things don't work (which, when you use the dig library as intended for startup resolution works well)
d.MustProvide(func() *http.Client {
return &http.Client{}
})
d.MustInvoke(func(c *http.Client) {
c.Do(...)
})When you're registering a lot of constructors, it gets tedious to call container.Provide(...) a lot, check all errors,
and then continue on.
This package includes functions to do multiple operations, like Provides(...), Invokes(...), etc, at the cost of the
Options.
d.Provides(
func() *http.Client {
return &http.Client{}
},
func() digext.Container {
return d
},
)