MCPcopy Create free account
hub / github.com/DoNewsCode/core / Name

Function Name

di/optional_provider.go:49–58  ·  view source on GitHub ↗

Name constructs a named instance. Name means to be used as an argument to graph.Provide. For example: Name(MyConstructor, "foo")

(constructor interface{}, name string)

Source from the content-addressed store, hash-verified

47// For example:
48// Name(MyConstructor, "foo")
49func Name(constructor interface{}, name string) interface{} {
50 if op, ok := constructor.(OptionalProvider); ok {
51 op.Options = append(op.Options, dig.Name(name))
52 return op
53 }
54 return OptionalProvider{
55 Constructor: constructor,
56 Options: []dig.ProvideOption{dig.Name(name)},
57 }
58}
59
60// Bind binds a type to another. Useful when binding implementation to
61// interfaces. The arguments should be a ptr to the binding types, rather than

Callers 2

TestNameFunction · 0.92
TestChainedOptionsFunction · 0.92

Calls

no outgoing calls

Tested by 2

TestNameFunction · 0.74
TestChainedOptionsFunction · 0.74