A lightweight configuration library for Go, inspired by viper.
Adder reads YAML config files and unmarshals them into Go structs, with support for environment variable overrides.
go get github.com/lwlee2608/adder# application.yaml
server:
host: localhost
port: 8080type Config struct {
Server struct {
Host string
Port uint
}
}
adder.SetConfigName("application")
adder.AddConfigPath(".")
adder.SetConfigType("yaml")
if err := adder.ReadInConfig(); err != nil {
panic(err)
}
var config Config
if err := adder.Unmarshal(&config); err != nil {
panic(err)
}- Case-insensitive YAML key matching
- YAML configuration with multiple search paths
- Automatic environment variable overrides via
AutomaticEnv() - Explicit env var binding via
BindEnv() mapstructurestruct tags for custom field mapping- Singleton and instance-based usage
See the example/ directory:
- basic — Load config from a YAML file
- env-override — Override config values with environment variables
- bind-env — Bind config keys to specific env var names