Documentation
¶
Index ¶
- Constants
- Variables
- func BuildAnyInstance(rootInstPtr any, referencePtr DependencyReferencePtr, instName string) (any, error)
- func BuildInstance[T any](rootInstPtr *T, referencePtr DependencyReferencePtr, instName string) (*T, error)
- func CallDependencyInjection(initMethod reflect.Method, inst any, reference DependencyReferencePtr) error
- func CreateInstance(rootTyp reflect.Type, referencePtr DependencyReferencePtr, instName string) (any, error)
- func EnableLog()
- func FullnameOfType(typ reflect.Type) string
- func GetMethodForReceiverType(typ reflect.Type, fnName string) (reflect.Method, bool)
- func SetUnexportedField(field reflect.Value, value interface{})
- type DependencyKey
- type DependencyReference
- type DependencyReferencePtr
- type DependencyStack
- type DependencyStackRecord
- type DiTag
- type InitializationHandler
- type InjectionHandler
Constants ¶
View Source
const ( TagName = "di" StackDeepKey = "__stack_deep__*" StackKey = "__stack__*" )
Variables ¶
View Source
var LogEnabled = false
Functions ¶
func BuildAnyInstance ¶ added in v0.0.9
func BuildAnyInstance(rootInstPtr any, referencePtr DependencyReferencePtr, instName string) (any, error)
func BuildInstance ¶ added in v0.0.6
func BuildInstance[T any](rootInstPtr *T, referencePtr DependencyReferencePtr, instName string) (*T, error)
func CallDependencyInjection ¶
func CallDependencyInjection(initMethod reflect.Method, inst any, reference DependencyReferencePtr) error
func CreateInstance ¶
func FullnameOfType ¶
func GetMethodForReceiverType ¶
GetMethodForReceiverType Get method for a receiver whose type is typ.
func SetUnexportedField ¶
Types ¶
type DependencyKey ¶
type DependencyKey = string
type DependencyReference ¶
type DependencyReference map[DependencyKey]any
type DependencyReferencePtr ¶
type DependencyReferencePtr = *DependencyReference
func (DependencyReferencePtr) Get ¶
func (r DependencyReferencePtr) Get(key string) (any, bool)
Get retrieves the dependent object.
func (DependencyReferencePtr) GetForDiField ¶
GetForDiField retrieves the injected instance for field
func (DependencyReferencePtr) StackCount ¶
func (r DependencyReferencePtr) StackCount() int
StackCount shows current stack count when running dependency inject. It should always be zero after run over CreateInstance. Just for debug.
func (DependencyReferencePtr) StackHistory ¶
func (r DependencyReferencePtr) StackHistory() (stack DependencyStack)
StackHistory retrieves the history for running dependency injection
type DependencyStack ¶
type DependencyStack []*DependencyStackRecord
func (DependencyStack) GetRecord ¶
func (s DependencyStack) GetRecord(index int) *DependencyStackRecord
func (DependencyStack) NumOfRecords ¶
func (s DependencyStack) NumOfRecords() int
type DependencyStackRecord ¶
func (DependencyStackRecord) InstType ¶
func (r DependencyStackRecord) InstType() reflect.Type
func (DependencyStackRecord) NameOfInstType ¶
func (r DependencyStackRecord) NameOfInstType() string
type DiTag ¶
type InitializationHandler ¶
type InitializationHandler interface { // DidDependencyInitialization will be called after initialization is completed. If receiver implements InjectionHandler // interface, InjectionHandler.DidDependencyInjection will be called first. DidDependencyInitialization() }
type InjectionHandler ¶
type InjectionHandler interface {
// DidDependencyInjection will be called after injection is completed.
DidDependencyInjection()
}
Click to show internal directories.
Click to hide internal directories.