Documentation ¶
Overview ¶
/ A dependency injection library for Go. / / This library provides the `Injector` type that is used for providing values and / after being configured with a collection of `Module`-s. / The library also provides iinterfaces for defining modules both from structs with provider methods and / dynamically generated providers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckModule ¶
CheckModule checks if the object is in fact a Module. Handles collections of modules correctly.
Types ¶
type Annotation ¶
type Annotation interface{}
/ Annotation is the interface that has to be implemented by all annotations. / It is empty, so implementation is trivial.
type DynamicModule ¶
type DynamicModule interface { Module /// Generate a list of providers. Providers() ([]Provider, error) }
/ Dynamic providers module. A type that, instead of having provider methods, / as with a static providers module, has a method for generating providers dynamically.
type Injector ¶
type Injector struct {
// contains filtered or unexported fields
}
Injector is a component for providing values exported by modules.
func InjectorOf ¶
Create an injector from the list of modules.
func (*Injector) Get ¶
func (self *Injector) Get(pointerToType interface{}, annotation Annotation) (interface{}, error)
Get the annotated value from the injector.
func (*Injector) MustGet ¶
func (self *Injector) MustGet(pointerToType interface{}, annotation Annotation) interface{}
Get the annotated value from the injector, panic if there was an error.
type Module ¶
type Module interface{}
/ Module is the interface that has to be implemented by all modules. / It is empty, so implementation is trivial. / In addition to this interface all Modules have to have methods that have two or three outputs: / - A value type. / - An annotation type. / - Optionally, an error. / These methods can have inputs that should come in pairs: values and their annotations.
func CombineModules ¶
Combine multiple modules into one.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
/ A dynamic provider is a type containing all the data about a provider that / the injector needs to be able to provide it.
func NewProvider ¶
func NewProvider(function interface{}) Provider
/ Create a new provider from either a function or a `reflect.Value` with a function.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
/ autoinject extends go-inject library with a way to automatically generate a provider / for a struct type.
|
/ autoinject extends go-inject library with a way to automatically generate a provider / for a struct type. |
examples
|
|
/ rewrite provides tools to dynamically transform modules to chenge their providers using reflection.
|
/ rewrite provides tools to dynamically transform modules to chenge their providers using reflection. |