| Crates.io | dotenv-flow |
| lib.rs | dotenv-flow |
| version | 0.16.2 |
| created_at | 2023-05-01 12:29:31.698802+00 |
| updated_at | 2023-11-16 10:58:49.144986+00 |
| description | A `dotenv-flow` implementation for Rust |
| homepage | https://github.com/cdellacqua/dotenv-flow.rs |
| repository | https://github.com/cdellacqua/dotenv-flow.rs |
| max_upload_size | |
| id | 853364 |
| size | 53,860 |
A fork of dotenv-rs that adds support for the popular dotenv-flow loading strategy.
The dotenv-flow strategy works as follows:
Each step will only load variables that are not already present in the environment, so for example variables in the .env.{DOTENV_ENV}.local file will have the highest priority, followed .env.local and so on.
cargo add dotenv-flow
To use this package, add the following line to your main function to load the environment variables from available .env.* files:
fn main() {
dotenv_flow::dotenv_flow().ok();
}
To test this project, make sure you pass --test-threads=1 to cargo test, e.g.
cargo test -- --test-threads=1
This is necessary because cargo test runs tests in multiple threads by default, but environment variables are process-globals, therefore we need to limit concurrency to avoid race conditions.