finds.dev

kelseyhightower/envconfig

Golang library for managing configuration data from environment variables

View on GitHub

★ 5,454GoMITupdated Jun 2025

// the take

A Go library that maps environment variables to struct fields via reflection. You define a config struct, call Process(), and it does the rest — type conversion, defaults, required-field enforcement. Aimed at any Go service that follows 12-factor config.

Handles the tedious cases correctly out of the box: time.Duration parsing, slice splitting, map decoding, and TextUnmarshaler/BinaryUnmarshaler for custom types. The custom Decoder interface is a clean escape hatch when the built-in parsing isn't enough. struct tags are minimal and readable — `required:"true"` and `default:"foobar"` are self-documenting. The codebase is tiny and stable; 5400 stars on ~400 lines means the surface area is well understood.

Required-but-empty variables pass validation — `MYAPP_REQUIREDVAR=` silently succeeds, which bites you when an orchestrator injects an empty string instead of omitting the var. No built-in support for validation beyond presence (no range checks, no enum validation). The `split_words` number-globbing behavior (numbers attach to the previous word) is a footgun documented only in the README, not in a compile-time error or warning. No schema export or documentation generation — you can't auto-generate a `.env.example` from the struct, so documentation tends to drift.

We read the README, the directory tree and a key source file in June 2026. Nobody pays to be listed. How we judge →

// at a glance

Stars
5,454
Forks
392
Language
Go
License
MIT
Last commit
28 Jun 2025

// nearby

If envconfig isn't quite it.

All repos →