Documentation ¶
Overview ¶
Package ioc provides a simple generics based registry which allows registering instance providers for a name and then instantiating instances, returning instances of the requested type.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Provider ¶
type Provider interface {
Get() any
}
Provider instances return instances of a given type. They may return singletons or a new instance each time
type ProviderF ¶
type ProviderF func() any
ProviderF is a function implementation of the Provider interface
type Registry ¶
type Registry interface { // Register adds a Provider for the given name Register(name string, provider Provider) // RegisterSingleton adds a Provider which always returns the given instance RegisterSingleton(name string, val interface{}) // GetProvider returns the Provider for the given name, or nil if no Provider has been // registered for the given name GetProvider(name string) Provider }
Registry instances store Providers keyed by name
Click to show internal directories.
Click to hide internal directories.