A Go library providing environment variable management with tree structures and struct population.
Envh is a Go library that simplifies environment variable management in applications. It provides two main components: an Env object that wraps environment variables with convenient helpers, and an EnvTree object that organizes variables into hierarchical structures similar to YAML or other configuration formats. It solves the problem of managing complex configuration setups by treating environment variables as structured data rather than flat key-value pairs.
Go developers building applications that require structured configuration management, such as web services, microservices, or CLI tools with hierarchical settings. It is particularly useful for teams needing to separate configuration from code for maintainability and flexibility.
Developers choose Envh over alternatives for its ability to organize environment variables into tree structures, automatically populate Go structs to reduce boilerplate, and support custom field setters for complex processing. Its unique selling point is the hierarchical management of environment variables, enabling configurations similar to YAML files directly from environment variables.
Go helpers to manage environment variables
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Organizes environment variables into tree structures, enabling complex setups similar to YAML files, as demonstrated by the EnvTree object for hierarchical storage.
Reduces boilerplate by populating Go structs directly from env vars, shown in the CONFIG2 example where PopulateStruct maps nested fields like DB and MAILER.
Allows custom field setters via the Walk method, enabling complex logic such as building URLs or processing maps, as illustrated in the setURL and setMap functions.
Automatically converts env var strings to Go types like int, float32, and bool, simplifying data handling without manual parsing.
The library adds verbosity for basic env var access; the example code is lengthy compared to using os.Getenv for flat configurations, making it overkill for trivial cases.
Struct population uses reflection, which can introduce performance overhead and reduce compile-time type safety compared to direct field mapping.
As a smaller library, it lacks the community support, plugins, and extensive documentation found in alternatives like Viper, relying mainly on godoc for examples.