dixinternal

package
v2.0.0-beta.17 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// InjectMethodPrefix can inject objects, as long as the method of this object contains a prefix of `InjectMethodPrefix`
	InjectMethodPrefix = "DixInject"
)

Variables

This section is empty.

Functions

func GetFnName

func GetFnName(fn reflect.Value) string

GetFnName returns the name of the function represented by reflect.Value

func GetProvideAllInputTypes

func GetProvideAllInputTypes(typ reflect.Type) []reflect.Type

GetProvideAllInputTypes returns all input types for a given type, including struct fields This is a public version of getProvideAllInputs that returns types instead of internal structures

func SetLog

func SetLog(handler slog.Handler)

Types

type Dix

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

func New

func New(opts ...Option) *Dix

New Dix new

func (*Dix) GetObjects

func (dix *Dix) GetObjects() map[reflect.Type]map[string][]reflect.Value

GetObjects returns a copy of the objects map for inspection This is useful for HTTP visualization endpoints

func (*Dix) GetProviderDetails

func (dix *Dix) GetProviderDetails() []ProviderDetails

GetProviderDetails returns detailed information about all providers

func (*Dix) GetProviders

func (dix *Dix) GetProviders() map[reflect.Type][]*providerFn

GetProviders returns a copy of the providers map for inspection This is useful for HTTP visualization endpoints

func (*Dix) Inject

func (dix *Dix) Inject(param any, opts ...Option) any

Inject injects dependencies into the given parameter. Panics on error. NOTE: Dix container is not thread-safe. Do not call Provide/Inject concurrently on the same container.

func (*Dix) Option

func (dix *Dix) Option() Options

func (*Dix) Provide

func (dix *Dix) Provide(param any)

Provide registers a provider function. Panics on error. NOTE: Dix container is not thread-safe. Do not call Provide/Inject concurrently on the same container.

func (*Dix) TryInject

func (dix *Dix) TryInject(param any, opts ...Option) error

TryInject injects dependencies into the given parameter. Returns error instead of panicking. NOTE: Dix container is not thread-safe. Do not call Provide/Inject concurrently on the same container.

func (*Dix) TryProvide

func (dix *Dix) TryProvide(param any) (err error)

TryProvide registers a provider function. Returns error instead of panicking. NOTE: Dix container is not thread-safe. Do not call Provide/Inject concurrently on the same container.

type Option

type Option func(opts *Options)

func WithValuesNull

func WithValuesNull() Option

type Options

type Options struct {
	// AllowValuesNull allows result to be nil
	AllowValuesNull bool
}

func (Options) Merge

func (o Options) Merge(opt Options) Options

func (Options) Validate

func (o Options) Validate() error

type ProviderDetails

type ProviderDetails struct {
	OutputType   string
	OutputPkg    string
	FunctionName string
	FunctionPkg  string
	InputTypes   []string
	InputPkgs    []string
}

ProviderDetails contains detailed information about a provider

Jump to

Keyboard shortcuts

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