Documentation
¶
Index ¶
- type Constructor
- type Container
- func (c *Container) Bind(name string, f Constructor)
- func (c *Container) Has(name string) bool
- func (c *Container) Instance(name string, value any)
- func (c *Container) Make(name string) (any, error)
- func (c *Container) MustMake(name string) any
- func (c *Container) Singleton(name string, f Constructor)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Container ¶
type Container struct {
// contains filtered or unexported fields
}
Container registers constructors by name and auto-wires their parameters. Registry locks never cover user constructors. Concurrent singleton resolution shares one construction per binding; independent bindings can build in parallel.
func (*Container) Bind ¶
func (c *Container) Bind(name string, f Constructor)
Bind registers a constructor called for each Make.
func (*Container) Make ¶
Make resolves a binding. Declared dependency cycles and ambiguous interface bindings return errors. Constructors may resolve independent bindings via Make; recursive cycles hidden inside constructor bodies must be avoided.
func (*Container) Singleton ¶
func (c *Container) Singleton(name string, f Constructor)
Singleton registers a constructor whose successful result is shared.
Click to show internal directories.
Click to hide internal directories.