samber / do

⚙️ A dependency injection toolkit based on Go 1.18+ Generics.
https://pkg.go.dev/github.com/samber/do
MIT License
1.82k stars 75 forks source link

Invoke multiple services satisfying the interface #29

Open flymedllva opened 1 year ago

flymedllva commented 1 year ago

Is it possible to do an Invoke of the providers corresponding to the interface and get them as a slice? And it would be great if they were initialized at the moment of such Invoke.

flymedllva commented 1 year ago

That is, I have a list of services that satisfy an interface and I want to get them, but I don't know the name and type of the structure that implements that interface.

I could call ListProvidedServices to look at the name and select the services I want, but I cannot get them because all services are different structures implementing 1 interface. I could do it through Get and manual conversion to the interface I need, but Get is unfortunately private.

Jictyvoo commented 1 year ago

@FlymeDllVa gonna link this issue here #33 as it looks pretty the same request