container

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2023 License: MIT Imports: 5 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConcreteFunc

type ConcreteFunc func(*Container) interface{}

type Container

type Container struct {
	// contains filtered or unexported fields
}

func New

func New() *Container

func (*Container) Bind

func (c *Container) Bind(abstract string, concrete ConcreteFunc, shared bool)

Bind Register a binding with the container.

func (*Container) Get

func (c *Container) Get(abstract string) (interface{}, error)

Get returns the instance of the given type from the container.

func (*Container) GetProviders

func (c *Container) GetProviders() []provider.Provider

GetProviders returns all registered providers.

func (*Container) Instance

func (c *Container) Instance(abstract string, concrete interface{})

Instance Set the given type to the container.

func (*Container) Make

func (c *Container) Make(abstract string) (interface{}, error)

Make resolve the given type from the container.

func (*Container) MustMake

func (c *Container) MustMake(abstract string) interface{}

MustMake Resolve the given type from the container or panic.

func (*Container) Register

func (c *Container) Register(provider provider.Provider)

Register registers a provider with the application.

func (*Container) Singleton

func (c *Container) Singleton(abstract string, concrete ConcreteFunc)

Singleton Register a shared binding in the container.

Jump to

Keyboard shortcuts

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