Documentation ¶
Overview ¶
Package go-inversify provides dependency injection for Go.
See the [README](https://github.com/alekns/goinversify/blob/master/README.md) for more details.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AutowireStruct ¶
AutowireStruct injects dependencies based on annotations and types
Types ¶
type Any ¶
type Any = interface{}
Any specifies abstract type
type AnyReturnFunc ¶
type AnyReturnFunc = interface{}
AnyReturnFunc defines pointer to an abstract function that returns only one single value
type Binding ¶
type Binding struct {
// contains filtered or unexported fields
}
Binding holds factory, specified dependencies and resolved dependencies
func (*Binding) InSingletonScope ¶
func (b *Binding) InSingletonScope()
InSingletonScope declares dependency as singleton
type Container ¶
type Container interface { // Bind declares dependency (make a panic if already binded) Bind(Any, ...string) *Binding // Rebind re-declares dependency (make a panic if not exists) Rebind(Any, ...string) *Binding // Unbind removes dependency Unbind(Any, ...string) Container // Get resolves dependency Get(Any, ...string) (Any, error) // Get resolves dependency and make a panic if error was produced MustGet(Any, ...string) Any // IsBound check existences of dependency IsBound(Any, ...string) bool // Build and resolves dependencies Build() // Merge with another container and returns new container Merge(container Container, name string) Container // SetParent supports for hierarchical DI systems SetParent(Container) // GetParent gets parent of container GetParent() Container // Load binds module Load(*Module) error // UnLoad unbinds module UnLoad(*Module) error }
Container holds dependencies graph
type ContainerBinder ¶
type ContainerBinder interface { // Bind declares dependency (make a panic if already binded) Bind(symbol Any) *Binding // Unbind removes dependency Unbind(symbol Any) // IsBound check existences of dependency IsBound(symbol Any) bool }
ContainerBinder holds interface to encapsulate bindings
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
Module .
func (*Module) Register ¶
func (mdl *Module) Register(callback func(ContainerBinder) error) *Module
Register .
func (*Module) UnRegister ¶
func (mdl *Module) UnRegister(callback func(ContainerBinder) error) *Module
UnRegister .
type PairDependencyName ¶
PairDependencyName holds dependency and name
func (PairDependencyName) String ¶
func (pair PairDependencyName) String() string
Click to show internal directories.
Click to hide internal directories.