Documentation
¶
Overview ¶
Package config provides typed configuration loading from YAML files with environment-variable overlay for the Krewire ecosystem.
Precedence is strictly: built-in zero values < file < environment. Later sources win.
Index ¶
Constants ¶
const DefaultPrefix = "APP"
DefaultPrefix is prepended to implicit environment keys derived from field names. Fields tagged `env:"KEY"` are always read from the exact key.
Variables ¶
This section is empty.
Functions ¶
func Load ¶
Load reads the YAML file at path and unmarshals it into dst (a non-nil pointer to a struct), binding values by `yaml` tag or lowercased field name. A missing file leaves dst at its zero value and returns nil; a malformed file returns a wrapped error naming the path.
func LoadOrDefault ¶
LoadOrDefault behaves like Load and is provided for tooling that tolerates an absent configuration file: a missing file yields the struct's zero value and never an error.
func Override ¶
Override applies environment values on top of an already-loaded struct. A field tagged `env:"KEY"` is read from the exact key; an untagged field derives an implicit key from its yaml tag/name uppercased with `-` and `.` replaced by `_`, prefixed by DefaultPrefix (or the prefix from WithPrefix), joining nested struct segments with `_` (e.g. `Server.Addr` -> APP_SERVER_ADDR). Empty environment values are treated as unset. Slices and maps are not overlaid in this phase.