Documentation
¶
Overview ¶
Package process provides reflection-based config struct hydration. It populates struct fields from environment variables, CLI flags, and default values using struct tags, then runs post-parse validation via the Processor interface.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PreProcess ¶
func PreProcess(target interface{}, flags *pflag.FlagSet) *diagnostic.Diagnostics
PreProcess walks the target struct and hydrates fields based on struct tags. Fields tagged with `env:"VAR"` are populated from environment variables, `default:"val"` sets a fallback when no env var is found and the field is zero, and `flag:"name"` registers a pflag on the provided FlagSet. Nested structs are recursed into unless they implement pflag.Value, in which case they are treated as leaf values. The target must be a pointer to a struct.
Types ¶
type Processor ¶
type Processor interface {
Process()
}
Processor is implemented by config structs that need post-parse validation or derived computation. Process is called depth-first (children before parents) after flags have been parsed.
type SharedFlag ¶
SharedFlag implementations can share the value they're give with other structs in a single operation.