Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Container ¶
type Container struct {
// contains filtered or unexported fields
}
func (*Container) Register ¶
func (c *Container) Register(provider interface{}, as ...interface{})
Register teaches container how to create an instance of the given type, for instance:
container.Register( // tell the container how to create an instance of *MyType func() *MyType { return &MyType{} }, ) container.Register( // tell the container how to create an instance of *MyOtherType from *MyType func(*MyType) *MyOtherType { ... }, // second argument registers *MyOtherType as MyOtherTypeInterface too. new(MyOtherTypeInterface), )
Register also registers resolvers for pointers to the type, so circular dependencies are possible:
container.Register(func(*MyOtherType) MyType { ... }) container.Register(func(*MyType) MyOtherTypeType { ... })
Click to show internal directories.
Click to hide internal directories.