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{})
| 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. |
| 144 | func (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. |