Documentation
¶
Index ¶
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
}
func NewContainer ¶
func NewContainer() (c *Container)
func (*Container) Populate ¶
func (c *Container) Populate(labelSelector FuncLabelSelector)
Populate call all provided functions then inject all provided and returned by function objects. It panics if any error occurs. Param labelSelector choice function with it's label. If nil passed, all function will selected.
func (*Container) Provide ¶
func (c *Container) Provide(objs ...interface{})
Provide panics if objs are not pointer to struct or interface.
func (*Container) ProvideByName ¶
ProvideByName panics if name is duplicate. Param name should match other object inject tag like `inject:"Name"`.
func (*Container) ProvideFunc ¶
func (c *Container) ProvideFunc(funcs ...InjectFunc)
ProvideFunc support function types:
- func() T
- func() (T, error)
If use unsupport function as arguments, it will panic. Param label is associated with fn and can be selected. Only selected function will call. If label is empty, by default it is selected.
func (*Container) ProvideFuncByName ¶
func (c *Container) ProvideFuncByName(name string, ifn InjectFunc)
ProvideFuncByName use `name` as object name, panic if name is duplicate.
type FuncLabelSelector ¶
type InjectFunc ¶
type InjectFunc struct {
Fn interface{} // func() T / func() (T, error)
Label string // default selected
}