box

package module
v1.0.0-beta.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2024 License: MIT Imports: 8 Imported by: 0

README

a zero dependency performant dependency injection library

Install

go get github.com/aacebo/box

Usage

b := box.New()
b.Put(&ServiceA{}, &ServiceB{})

fn, err := b.Inject(func (a *ServiceA, b *Service B) {
	fmt.Println(a, b)
})

if err != nil {
	panic(err)
}

fn()

Benchmarks

  • coming soon!

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get[T any](box *Box) T

func GetByKey

func GetByKey[T any](box *Box, key string) T

Types

type Box

type Box struct {
	context.Context
	// contains filtered or unexported fields
}

func New

func New() *Box

func (*Box) Deadline

func (self *Box) Deadline() (deadline time.Time, ok bool)

func (*Box) Done

func (self *Box) Done() <-chan struct{}

func (*Box) Err

func (self *Box) Err() error

func (*Box) Fork

func (self *Box) Fork() *Box

func (*Box) Inject

func (self *Box) Inject(handler any) (func(), error)

func (*Box) Len

func (self *Box) Len() int

func (*Box) Put

func (self *Box) Put(values ...any)

func (*Box) PutByKey

func (self *Box) PutByKey(key string, value any)

func (*Box) String

func (self *Box) String() string

func (*Box) Value

func (self *Box) Value(key any) any

Jump to

Keyboard shortcuts

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