A zero-dependency Go library for parsing environment variables into typed structs.
env is a Go library that simplifies configuration management by parsing environment variables directly into typed structs. It eliminates manual parsing and type conversion, making application configuration cleaner and more type-safe through a declarative, struct-tag-based approach.
Go developers building applications that require configuration via environment variables, particularly those seeking a type-safe, zero-dependency solution for managing settings in cloud-native, containerized, or 12-factor apps.
Developers choose env for its simplicity and zero dependencies, offering robust type support and flexible parsing options without adding external library bloat. Its struct-tag-driven design provides a clean, declarative way to handle environment variables with built-in validation, defaults, and support for complex types.
A simple, zero-dependencies library to parse environment variables into structs
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
With no external libraries, env keeps Go builds minimal and fast, reducing dependency bloat and simplifying maintenance, as highlighted in the README's philosophy.
Handles built-in Go types, pointers, slices, maps, and complex types like time.Duration and url.URL, plus custom types via encoding.TextUnmarshaler, offering extensive out-of-the-box functionality.
Uses struct tags like `required` and `envDefault` to enforce rules and set defaults, eliminating boilerplate code for common configuration checks.
Supports reading values from files with the `file` tag and expanding nested environment variables via the `expand` tag, adding flexibility for security and dynamic configurations.
Offers generics support, custom prefixes, and hooks through ParseWithOptions, allowing fine-grained control over parsing behavior without compromising simplicity.
By design, env skips unexported fields in structs, which can hinder encapsulation and force workarounds for internal configuration management, as noted in the README caveats.
Focuses solely on env vars; for applications needing multi-source config (e.g., YAML or CLI flags), env requires complementary tools or manual integration, adding complexity.
Relies on Go's reflection for parsing, which may introduce performance overhead in very high-load scenarios compared to direct, manual parsing methods.
The project is considered feature-complete with limited new development, potentially lagging behind evolving configuration needs unless community requests drive changes.