We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is it possible to override a value that is already defined in a parent container?
For example, let's say I want to override the Logger for a specific DI container like this
type Logger interface { } type Logger1 struct{} type Logger2 struct{} func main() { root, err := di.New( di.ProvideValue(Logger1{}, di.As(new(Logger))), ) if err != nil { panic(err) } child, err := di.New( di.ProvideValue(Logger2{}, di.As(new(Logger))), ) if err != nil { panic(err) } err = child.AddParent(root) if err != nil { panic(err) } var lg Logger err = child.Resolve(&lg) if err != nil { panic(err) } }
I get
multiple definitions of main.Logger, maybe you need to use group type: []main.Logger
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Is it possible to override a value that is already defined in a parent container?
For example, let's say I want to override the Logger for a specific DI container like this
I get
The text was updated successfully, but these errors were encountered: