A minimalistic Go library for reading configuration from environment variables and files with struct tags.
Cleanenv is a Go library for reading application configuration from environment variables and files into structured Go types. It solves the problem of managing configuration across different sources (like YAML files and environment variables) in a clean, type-safe way without complex abstractions.
Go developers building applications that require configuration management from multiple sources, especially those working on CLI tools, microservices, or containerized applications.
Developers choose Cleanenv for its minimalistic design, explicit configuration via struct tags, and lack of external dependencies, making it easy to integrate and maintain compared to heavier configuration libraries.
✨Clean and minimalistic environment configuration reader for Golang
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Reads from both files (YAML, JSON, TOML, etc.) and environment variables into a single struct, with environment variables automatically overriding file values, as demonstrated in the ReadConfig example.
Uses Go struct tags like env and env-default to define configuration mapping, making it clear and type-safe without external dependencies, aligning with its simplicity philosophy.
Allows marking fields with env-upd to refresh values from environment variables during runtime using UpdateEnv, useful for dynamic systems like distributed architectures.
Generates environment variable descriptions via env-description tags and GetDescription function, aiding in CLI help generation and documentation.
Lacks built-in support for remote configuration sources or complex validation (e.g., regex), requiring custom implementations via Setter and Updater interfaces.
When using .env files, it overrides existing process environment variables, which can cause unintended side-effects in deployments where env vars are managed externally.
Managing struct tags for deeply nested or numerous configuration fields can become cumbersome and error-prone, especially without IDE tooling support.