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

How to pass structs as inputs for those services #39

Closed aphsa closed 10 months ago

aphsa commented 1 year ago

How to pass structs as inputs for those services. We only have ProvideNamedValues which allows only strings

samber commented 10 months ago

Hi @aphsa

The string given to do.ProvideNamedValue is the service name.

You can also let the framework infer the name from service type by using do.Provide[*MyService](injector, &myService)