Documentation
¶
Index ¶
- func LoadDotEnv(path string) error
- func ParseDotEnv(data []byte) ([]dotenvPair, error)
- type Config
- func (c Config) Delete(key string)
- func (c Config) EnvOverride(prefix string) Config
- func (c Config) Get(key string) string
- func (c Config) GetOr(key, fallback string) string
- func (c Config) Keys() []string
- func (c Config) Merge(other Config) Config
- func (c Config) Save(path string) error
- func (c Config) Set(key, value string)
- func (c Config) WithDefaults(defaults Config) Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadDotEnv ¶
LoadDotEnv parses the .env file at path and exports its KEY=VALUE pairs into the process environment (KWL-Q7X4M KWL-DOTV-001). Variables already present in the process environment are never overwritten, so real environment wins over .env. A missing file is not an error.
func ParseDotEnv ¶
ParseDotEnv parses .env file content into ordered KEY=VALUE pairs. Blank lines and # comments are skipped; an optional "export " prefix is accepted; values may be wrapped in single or double quotes (KWL-Q7X4M KWL-DOTV-002).
Types ¶
type Config ¶
Config represents the key-value configuration store. It's a simple string-to-string map that can be loaded from and saved to YAML files.
func Load ¶
Load reads a YAML file and returns a Config map. If the file doesn't exist, it returns an empty Config (not an error).
func (Config) EnvOverride ¶
EnvOverride applies environment variables with the given prefix. Environment variables are converted to lower-case keys with dots. e.g., APP_SERVER_PORT=8080 -> server.port
func (Config) GetOr ¶
GetOr returns the value for key, or fallback when the key is absent. It is the lookup primitive for config getters that read environment variables with in-code defaults (KWN-Q7X4M).
func (Config) WithDefaults ¶
Defaults returns a new Config with default values applied (non-destructive).