Documentation
¶
Index ¶
- Variables
- func GetConf(base string, config interface{}) error
- func GetConfigFilesWithExt(files ...string) ([]string, error)
- func Load(config interface{}, opts ...Option) error
- func LoadConfigFileNoExt(config interface{}, base string) error
- func LoadConfigFiles(config interface{}, files ...string) error
- func LoadJSON(filename string, configuration interface{}) error
- func LoadTOML(filename string, configuration interface{}) error
- func LoadYAML(filename string, configuration interface{}) error
- type Option
Constants ¶
This section is empty.
Variables ¶
var ErrNoSources = errors.New("konfig: no configuration sources found")
ErrNoSources indicates that no configuration sources produced any value.
Functions ¶
func GetConf ¶
GetConf preserves the legacy API of resolving a base filename (without extension) and populating config based on the first available source.
func GetConfigFilesWithExt ¶
GetConfigFilesWithExt returns the subset of files that exist as regular files, preserving the provided order. It returns ErrNoSources if none exist.
func Load ¶
Load populates config by reading from the declared files and environment variables, returning ErrNoSources when nothing supplies a value. The config argument must be a non-nil pointer to a struct (or a struct of structs).
func LoadConfigFileNoExt ¶
LoadConfigFileNoExt attempts to load configuration using a base filename, trying JSON, TOML, then YAML in that order.
func LoadConfigFiles ¶
LoadConfigFiles sequentially loads the provided files, allowing later files to override earlier ones.
Types ¶
type Option ¶
type Option func(*options)
Option modifies how Load discovers and applies configuration.
func WithEnvPrefix ¶
WithEnvPrefix configures a prefix that is prepended to every generated environment variable key. Nested struct names are appended using underscores.