uber-go / dig

A reflection based dependency injection toolkit for Go.
https://go.uber.org/dig
MIT License
3.78k stars 206 forks source link

Returns an existing Scope with the same name #401

Open Tiscs opened 8 months ago

Tiscs commented 8 months ago

Returns an existing Scope with the same name when calling Scope(name string, opts ...ScopeOption) rather than creating a new one.

CLAassistant commented 8 months ago

CLA assistant check
All committers have signed the CLA.

JacobOaks commented 6 months ago

Hi @Tiscs, in its current state this is a breaking change because it was cause all current calls to Scope() with the same name to be merged into one scope which could break some users.

Instead, we could add a new API to scope that returns a child subscope with a given name, or perhaps an Option that you pass when creating the container that enables this behavior. Let me know your thoughts!