Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Container ¶
type Container struct {
// contains filtered or unexported fields
}
Container is a simple dependency injection container. It supports registering constructors or values and resolving them by type. Constructor functions are called once and cached as singletons.
func (*Container) Inject ¶
Inject fills struct fields tagged with `inject:""` using the container. target must be a pointer to a struct.
Lazy first-time resolution of a func-provider writes the shared singletons/resolved maps, so the whole method takes the full write lock (c.mu.Lock), mirroring Resolve. Using an RLock here would let two concurrent cold-start injections of the same type write the same map simultaneously — an unrecoverable "concurrent map writes" crash.