← All projects

darvaza.org/x/config

Helpers for handling config structs — decoding, defaults, and validation.

Format-agnostic configuration loader. A generic Loader[T] tries candidate filenames in order, decodes via a user-supplied Decoder (TOML, YAML, JSON — any format works), applies struct-tag defaults, expands shell-style ${VAR} variables, and validates the result with go-playground/validator.

Subpackage config/expand provides mvdan.cc/sh-powered variable substitution from any source. Subpackage config/appdir handles XDG/FHS-aware directory discovery (UserConfigDir, SysConfigDir, AllConfigDir).