Documentation
¶
Index ¶
- func Get[I any](c *Container) (I, error)
- func GetByName(c *Container, name string) (any, error)
- func MustGet[I any](c *Container) I
- func MustPopulate[T any](c *Container, target *T, options ...option) *T
- func Populate[T any](c *Container, target *T, options ...option) (*T, error)
- func Register[T any](c *Container, empty T, options ...option)
- func RegisterBasicValue[T any](c *Container, value T)
- func WithFunctionInject(enable bool) option
- func WithFunctionInjectName(name string) option
- func WithReplacerFunction(replacerFunction any) option
- func WithStructDefaultInject(enable bool) option
- func WithStructInject(enable bool) option
- func WithStructTag(tag string) option
- type Container
- type PostInject
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MustPopulate ¶ added in v0.0.2
MustPopulate is like Populate but panics if injection fails.
func Populate ¶ added in v0.0.2
Populate injects dependencies into target using the same injection pipeline as Register+Get, but without adding target to c. Because target is never added to c, no other service can receive it as a dependency, and a struct that (transitively) depends on its own type will fail with a "not found" error — unlike Register+Get, which can resolve direct self-cycles because the service is already present in the container before recursion happens.
func RegisterBasicValue ¶
func WithFunctionInject ¶
func WithFunctionInject(enable bool) option
func WithFunctionInjectName ¶
func WithFunctionInjectName(name string) option
func WithReplacerFunction ¶
func WithReplacerFunction(replacerFunction any) option
func WithStructDefaultInject ¶
func WithStructDefaultInject(enable bool) option
func WithStructInject ¶
func WithStructInject(enable bool) option
func WithStructTag ¶
func WithStructTag(tag string) option
Types ¶
type Container ¶
type Container struct {
// contains filtered or unexported fields
}
func NewContainer ¶
func NewContainer(defaultOptions ...option) *Container
type PostInject ¶
type PostInject interface {
PostInject()
}
Click to show internal directories.
Click to hide internal directories.