container

package
v2.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 21, 2021 License: MIT Imports: 2 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Container

type Container map[reflect.Type]binding

Container is the repository of bindings

func NewContainer

func NewContainer() Container

NewContainer creates a new instance of Container

func (Container) Make

func (c Container) Make(receiver interface{}) error

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 existing bindings.

func (Container) Singleton

func (c Container) Singleton(resolver interface{}) error

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{}) error

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL