MCPcopy Index your code
hub / github.com/DoNewsCode/core / As

Function As

di/optional_provider.go:35–44  ·  view source on GitHub ↗

As constructs the instance and bind it to another interface. As means to be used as an argument to graph.Provide. For example: As(MyConstructor, new(MyAbstractInterface))

(constructor interface{}, as interface{})

Source from the content-addressed store, hash-verified

33// For example:
34// As(MyConstructor, new(MyAbstractInterface))
35func As(constructor interface{}, as interface{}) interface{} {
36 if op, ok := constructor.(OptionalProvider); ok {
37 op.Options = append(op.Options, dig.As(as))
38 return op
39 }
40 return OptionalProvider{
41 Constructor: constructor,
42 Options: []dig.ProvideOption{dig.As(as)},
43 }
44}
45
46// Name constructs a named instance. Name means to be used as an argument to graph.Provide.
47// For example:

Callers 2

TestAsFunction · 0.92
TestChainedOptionsFunction · 0.92

Calls

no outgoing calls

Tested by 2

TestAsFunction · 0.74
TestChainedOptionsFunction · 0.74