inject
Dependency injection for go
This a modified version of codegangsta/inject.
And refer to flamego/flamego/inject.
中文
Usage
func InterfaceOf
func InterfaceOf(value interface{}) reflect.Type
InterfaceOf dereferences a pointer to an Interface type. It panics if value is
not an pointer to an interface.
type Applicator
type Applicator interface {
Apply(interface{}) error
}
Applicator represents an interface for mapping dependencies to a struct.
type Injector
type Injector interface {
Applicator
Invoker
TypeMapper
Reset()
SetParent(Injector) Injector
}
Injector represents an interface for mapping and injecting dependencies into
structs and function arguments.
func New
func New() Injector
New returns a new Injector.
type Invoker
type Invoker interface {
Invoke(interface{}) ([]reflect.Value, error)
}
Invoker represents an interface for calling functions via reflection.
type TypeMapper
type TypeMapper interface {
Map(interface{}) TypeMapper
MapTo(val interface{}, pointerToInterface interface{}) TypeMapper
Set(reflect.Type, reflect.Value) TypeMapper
Get(reflect.Type) reflect.Value
}
TypeMapper represents an interface for mapping interface{} values based on type.