Documentation ¶
Overview ¶
Package dig
@author: xwc1125
Index ¶
- Variables
- func FirstUpper(s string) string
- type Container
- func (p *Container) Ensure(instance interface{}) error
- func (p *Container) Ensures(instances ...interface{}) error
- func (p *Container) GetPrototype(name string) (interface{}, error)
- func (p *Container) GetSingleton(name string) interface{}
- func (p *Container) SetPrototype(name string, factory factory)
- func (p *Container) SetSingleton(name string, singleton interface{})
- func (p *Container) String() string
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrFactoryNotFound = errors.New("factory not found")
)
Functions ¶
Types ¶
type Container ¶
Container 容器
func (*Container) Ensure ¶
Ensure 注入依赖 该方法扫描实例的所有export字段,并读取di标签,如果有该标签则启动注入。 判断di标签的类型来确定注入singleton或者prototype对象
func (*Container) GetPrototype ¶
GetPrototype 获取实例对象
func (*Container) GetSingleton ¶
GetSingleton 获取单例对象
func (*Container) SetPrototype ¶
SetPrototype 设置实例对象工厂
func (*Container) SetSingleton ¶
SetSingleton 注册单例对象
Click to show internal directories.
Click to hide internal directories.