Documentation
¶
Overview ¶
Package container provides an IoC container for Go projects. It provides simple, fluent and easy-to-use interface to make dependency injection in GoLang easier.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Container ¶
Container is a map of reflect.Type to binding
func (Container) Make ¶
func (c Container) Make(receiver interface{})
Make will resolve the dependency and return a appropriate concrete of the given abstraction. It can take an abstraction (interface reference) and fill it with the related implementation. It also can takes a function (receiver) with one or more arguments of the abstractions (interfaces) that need to be resolved, Container will invoke the receiver function and pass the related implementations.
func (Container) Reset ¶
func (c Container) Reset()
Reset will reset the container and remove all the bindings.
func (Container) Singleton ¶
func (c Container) Singleton(resolver interface{})
Singleton will bind an abstraction to a concrete for further singleton resolves. It takes a resolver function which returns the concrete and its return type matches the abstraction (interface). The resolver function can have arguments of abstraction that have bound already in Container.
func (Container) Transient ¶
func (c Container) Transient(resolver interface{})
Transient will bind an abstraction to a concrete for further transient resolves. It takes a resolver function which returns the concrete and its return type matches the abstraction (interface). The resolver function can have arguments of abstraction that have bound already in Container.