di

package
v0.0.0-...-3e624d3 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate(register func(*Container))

Generate code for type initializers in the context of the resolved container.

Types

type Container

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

Container is a generic dependency container.

func NewContainer

func NewContainer() *Container

NewContainer creates an empty container.

func (*Container) Build

func (c *Container) Build() error

Build the container.

func (*Container) Get

func (c *Container) Get(typ interface{}) interface{}

Get returns a built dependency by type.

func (*Container) Range

func (c *Container) Range(f func(item *Item) bool)

Range over the container items in dependency order.

func (*Container) Register

func (c *Container) Register(provider interface{})

Register registers a provider function for a type.

func (*Container) Resolve

func (c *Container) Resolve() error

Resolve the container.

type Item

type Item struct {
	Value interface{}
	// contains filtered or unexported fields
}

An Item is a container item.

Jump to

Keyboard shortcuts

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