Skip to main content
Version: In development — v0.2.3

Dependency injection

The optional di package resolves dependencies from constructor input and output types.

container := di.NewContainer()
container.AddDependencies([]any{newRepository, newService})
container.StartApp(start)

Each constructor must return exactly one value. Dependencies are resolved by concrete type or interface. Missing or ambiguous constructors panic.

caution

Resolution uses reflection and fails at runtime. Keep a test that initializes the complete dependency graph.

See the SDK example.