Documentation
¶
Overview ¶
Package inheritance is a hierarchical config resolver: combine multiple partial-config layers (defaults → env → scope → instance) into a fully-realised config by taking the highest-priority definition per field.
Each field is wrapped in Optional[T] to distinguish "set" from "unset". Append-merge for slices and union-merge for maps are available via the `cfg:"...,merge=…"` tag; the default is override.
Complements kit/sops + envconfig (boot-time parsing) by handling runtime layered lookup with merging.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Layer ¶
Layer is one priority level in a hierarchical config. Higher-index layers (added later via AddLayer) override lower ones.
type Optional ¶
type Optional[T any] struct { // contains filtered or unexported fields }
Optional is a "set or unset" wrapper used in Layer structs.
func (Optional[T]) MarshalJSON ¶
MarshalJSON emits the underlying value when set, JSON null when unset, so round-trips don't accidentally promote unset → zero.
func (Optional[T]) OrDefault ¶
func (o Optional[T]) OrDefault(d T) T
OrDefault returns the value if set, otherwise d.
func (*Optional[T]) UnmarshalJSON ¶
UnmarshalJSON treats JSON null as Unset; any other value as Set.
type ResolutionError ¶
ResolutionError is one structured per-field problem from Resolve.
func (ResolutionError) Error ¶
func (e ResolutionError) Error() string
Error implements the error interface.
type Resolver ¶
type Resolver[T any] struct { // contains filtered or unexported fields }
Resolver merges layers of T into a final T.
func (*Resolver[T]) Resolve ¶
func (r *Resolver[T]) Resolve() (T, []ResolutionError)
Resolve produces a fully-realised T plus any per-field errors (required fields unset, type mismatches).