Documentation
¶
Overview ¶
Package container is a lightweight yet powerful IoC container for Go projects. It provides an easy-to-use interface and performance-in-mind container to be your ultimate requirement.
Index ¶
- func Call(receiver interface{}) error
- func Fill(receiver interface{}) error
- func NamedResolve(abstraction interface{}, name string) error
- func NamedSingleton(name string, resolver interface{}) error
- func NamedTransient(name string, resolver interface{}) error
- func Reset()
- func Resolve(abstraction interface{}) error
- func Singleton(resolver interface{}) error
- func Transient(resolver interface{}) error
- type Container
- func (c Container) Call(function interface{}) error
- func (c Container) Fill(structure interface{}) error
- func (c Container) NamedResolve(abstraction interface{}, name string) error
- func (c Container) NamedSingleton(name string, resolver interface{}) error
- func (c Container) NamedTransient(name string, resolver interface{}) error
- func (c Container) Reset()
- func (c Container) Resolve(abstraction interface{}) error
- func (c Container) Singleton(resolver interface{}) error
- func (c Container) Transient(resolver interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Call ¶
func Call(receiver interface{}) error
Call takes a function (receiver) with one or more arguments of the abstractions (interfaces). It invokes the function (receiver) and passes the related implementations.
func Fill ¶
func Fill(receiver interface{}) error
Fill takes a struct and resolves the fields with the tag `container:"inject"`
func NamedResolve ¶
NamedResolve resolves like the Resolve method but for named bindings.
func NamedSingleton ¶
NamedSingleton binds like the Singleton method but for named bindings.
func NamedTransient ¶
NamedTransient binds like the Transient method but for named bindings.
func Reset ¶
func Reset()
Reset deletes all the existing bindings and empties the container instance.
func Resolve ¶
func Resolve(abstraction interface{}) error
Resolve takes an abstraction (interface reference) and fills it with the related implementation.
func Singleton ¶
func Singleton(resolver interface{}) error
Singleton binds an abstraction to concrete for further singleton resolves. It takes a resolver function that returns the concrete, and its return type matches the abstraction (interface). The resolver function can have arguments of abstraction that have been declared in the Container already.
func Transient ¶
func Transient(resolver interface{}) error
Transient binds an abstraction to concrete for further transient resolves. It takes a resolver function that returns the concrete, and its return type matches the abstraction (interface). The resolver function can have arguments of abstraction that have been declared in the Container already.
Types ¶
type Container ¶ added in v3.1.4
Container holds all of the declared bindings
func (Container) Call ¶ added in v3.1.4
Call takes a function (receiver) with one or more arguments of the abstractions (interfaces). It invokes the function (receiver) and passes the related implementations.
func (Container) Fill ¶ added in v3.1.4
Fill takes a struct and resolves the fields with the tag `container:"inject"`
func (Container) NamedResolve ¶ added in v3.1.4
NamedResolve resolves like the Resolve method but for named bindings.
func (Container) NamedSingleton ¶ added in v3.1.4
NamedSingleton binds like the Singleton method but for named bindings.
func (Container) NamedTransient ¶ added in v3.1.4
NamedTransient binds like the Transient method but for named bindings.
func (Container) Reset ¶ added in v3.1.4
func (c Container) Reset()
Reset deletes all the existing bindings and empties the container instance.
func (Container) Resolve ¶ added in v3.1.4
Resolve takes an abstraction (interface reference) and fills it with the related implementation.
func (Container) Singleton ¶ added in v3.1.4
Singleton binds an abstraction to concrete for further singleton resolves. It takes a resolver function that returns the concrete, and its return type matches the abstraction (interface). The resolver function can have arguments of abstraction that have been declared in the Container already.
func (Container) Transient ¶ added in v3.1.4
Transient binds an abstraction to concrete for further transient resolves. It takes a resolver function that returns the concrete, and its return type matches the abstraction (interface). The resolver function can have arguments of abstraction that have been declared in the Container already.