A Go library for loading environment variables into structs using struct tags.
env is a Go library that provides tag-based environment configuration for structs. It automatically loads environment variables into struct fields using struct tags, handling type conversion, validation, and default values. It solves the problem of writing repetitive and error-prone code to parse and validate environment variables in Go applications.
Go developers building applications that require configuration via environment variables, particularly those working on microservices, CLI tools, or containerized applications where environment-based configuration is standard.
Developers choose env because it offers a declarative, type-safe, and minimal approach to configuration that eliminates boilerplate code. Its support for required fields, default values, and complex types like slices makes it more robust than manual parsing or simpler alternatives.
Tag-based environment configuration for 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.
Uses Go struct tags like `env:"VARNAME"` to map environment variables, eliminating manual parsing boilerplate as shown in the usage example.
Handles parsing of various Go types including bool, ints, floats, and time.Duration from strings, reducing conversion errors.
Supports required fields with `required:"true"` tags and default values via `default` tags, ensuring configuration integrity without extra code.
Can parse environment variables into slices with customizable delimiters, useful for lists like PEERS in the example.
The library only works with flat structs; it doesn't handle nested or hierarchical configurations, limiting its use for complex setups.
Only supports required checks and defaults; lacks custom validation rules, regex patterns, or conditional logic for more advanced scenarios.
Relies heavily on correct struct tags, which can lead to runtime errors if tags are misspelled or environment variable names change.