Release Notes
This is the initial release of envconfig, a Go library that automatically populates configuration structs from environment variables. It provides a simple, zero-code-change approach to app configuration, making it easy for Go developers to get a working configuration-loading setup in minutes.
New features
- Automatic struct population from environment variablesDefine a Go struct with field tags and envconfig will automatically read matching environment variables and populate the struct. No manual os.Getenv calls required. Example: ```go type Config struct { Port int `env:"PORT"` Host string `env:"HOST"` } var cfg Config if err := envconfig.Process(ctx, &cfg); err != nil { log.Fatal(err) } ```
- Required field validationMark fields as required using struct tags. envconfig will return an error at startup if a required environment variable is missing, preventing misconfigured deployments. ```go type Config struct { DatabaseURL string `env:"DATABASE_URL, required"` } ```
- Default value supportSpecify fallback default values for fields that are not set in the environment, keeping configuration flexible without sacrificing safety. ```go type Config struct { Port int `env:"PORT, default=8080"` } ```
- Support for common Go typesAutomatically parses environment variable strings into native Go types including string, bool, int/int64, float64, time.Duration, and slices — no manual type conversion needed.
- Nested struct supportOrganize configuration into nested structs with prefix support, keeping large configurations clean and modular. ```go type Config struct { Database DatabaseConfig `env:", prefix=DB_"` } type DatabaseConfig struct { Host string `env:"HOST"` Port int `env:"PORT"` } ```
- Custom type decodingImplement the Decoder interface on any custom type to control exactly how environment variable strings are parsed into your own types.