MCPcopy Create free account
hub / github.com/golobby/container / Singleton

Method Singleton

container.go:144–146  ·  view source on GitHub ↗

Singleton binds an abstraction to concrete in singleton mode. It takes a resolver function that returns the concrete, and its return type matches the abstraction (interface). The resolver function can have arguments of abstraction that have been declared in the Container already.

(resolver interface{})

Source from the content-addressed store, hash-verified

142// It takes a resolver function that returns the concrete, and its return type matches the abstraction (interface).
143// The resolver function can have arguments of abstraction that have been declared in the Container already.
144func (c Container) Singleton(resolver interface{}) error {
145 return c.bind(resolver, "", true, false)
146}
147
148// SingletonLazy binds an abstraction to concrete lazily in singleton mode.
149// The concrete is resolved only when the abstraction is resolved for the first time.

Calls 1

bindMethod · 0.95