Load environment variables from .env files or io.Reader in Go applications.
Gotenv is a Go library for loading environment variables from `.env` files or any `io.Reader` source. It simplifies configuration management by allowing developers to define environment-specific variables in files, making applications more portable and easier to configure across different environments.
Go developers building applications that require environment-specific configuration, such as web servers, CLI tools, or microservices, who want to manage settings via files without embedding them in code.
Developers choose gotenv for its straightforward port of the dotenv pattern to Go, offering flexible loading from files or readers, explicit control over overriding existing variables, and seamless integration with Go's standard library and ecosystem.
Load environment variables from .env or io.Reader in Go.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Supports loading from multiple .env files where the first value wins, as demonstrated in the Load function with filenames like ".env.production" and "credentials".
Allows applying variables from any io.Reader, such as strings or network streams, using the Apply function, offering flexibility beyond file-based sources.
Provides separate functions (Load/Apply vs OverLoad/OverApply) to choose whether to override existing environment variables, ensuring predictable behavior.
Includes a Must helper that panics on errors, enabling applications to fail quickly during startup if configuration is missing or invalid.
The library loads variables at initialization (e.g., in init()) and lacks built-in support for live configuration updates without restarting the application.
While it handles simple variable expansion (e.g., BAR=$FOO), it may not support advanced features like nested variables or environment-specific logic beyond basic dotenv compatibility.
Relies on .env files which can pose security risks if sensitive data is stored in plaintext, and the library doesn't enforce encryption or secure handling practices.