{"id":21616009,"url":"https://github.com/darkwebdesign/rust-dotenv","last_synced_at":"2025-03-18T17:19:46.321Z","repository":{"id":57616130,"uuid":"284532015","full_name":"darkwebdesign/rust-dotenv","owner":"darkwebdesign","description":"A library that eases configuration via .env environment files","archived":false,"fork":false,"pushed_at":"2020-08-02T20:06:47.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-24T20:45:52.428Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/darkwebdesign.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-08-02T19:59:58.000Z","updated_at":"2020-08-02T20:06:49.000Z","dependencies_parsed_at":"2022-08-27T07:31:14.994Z","dependency_job_id":null,"html_url":"https://github.com/darkwebdesign/rust-dotenv","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darkwebdesign%2Frust-dotenv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darkwebdesign%2Frust-dotenv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darkwebdesign%2Frust-dotenv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darkwebdesign%2Frust-dotenv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/darkwebdesign","download_url":"https://codeload.github.com/darkwebdesign/rust-dotenv/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244267475,"owners_count":20425835,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-24T22:13:22.006Z","updated_at":"2025-03-18T17:19:46.297Z","avatar_url":"https://github.com/darkwebdesign.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dotenv component\n\nThe Dotenv component parses `.env` files to make environment variables stored in them accessible via `std::env`.\n\n## Installation\n\nAdd the dependency to your `Cargo.toml`:\n\n```toml\n[dependencies]\ndarkweb-dotenv = \"^1.0\"\n```\n\n## Usage\n\nSensitive information and environment-dependent settings should be defined as environment variables (as recommended for\n[twelve-factor applications](http://www.12factor.net/)). Using a `.env` file to store those environment variables eases\ndevelopment and CI management by keeping them in one \"standard\" place and agnostic of the technology stack you are\nusing.\n\n```dotenv\n# .env\nDB_USER=root\nDB_PASS=pass\n```\n\nLoad a `.env` file in your application via `Dotenv::load()`:\n\n```rust\nuse darkweb_dotenv::Dotenv;\n\nlet mut dotenv = Dotenv::new();\ndotenv.load(\".env\").unwrap();\n```\n\nAccess the values with `std::env` in your code:\n\n```rust\nlet db_user = std::env::var(\"DB_USER\").unwrap();\n```\n\nThe `load()` method never overwrites existing environment variables. Use the `overload()` method if you need to\noverwrite them:\n\n```rust\n// ...\ndotenv.overload(\".env\").unwrap();\n```\n\nAs you're working with the Dotenv component you'll notice that you might want to have different files depending on the\nenvironment you're working in. Typically this happens for local development or Continuous Integration where you might\nwant to have different files for your `test` and `dev` environments.\n\nYou can use `Dotenv::load_env()` to ease this process:\n\n```rust\n// ...\ndotenv.load_env(\".env\", \"APP_ENV\", \"dev\").unwrap();\n```\n\nThe Dotenv component will then look for the correct `.env` files to load. If the environment variable `APP_ENV` is\ndefined, its value is used to load environment-specific files. If the variable is not defined, `dev` is assumed for\n`APP_ENV`.\n\nThe following files are loaded if they exist, the latter taking precedence over the former:\n\n* `.env` --\u003e committed environment defaults\n* `.env.local` --\u003e uncommitted file with local overrides\n* `.env.{APP_ENV}` --\u003e committed environment-specific defaults\n* `.env.{APP_ENV}.local` --\u003e uncommitted environment-specific local overrides\n\n## Links\n\n* Documentation: https://docs.rs/darkweb-dotenv\n* Repository: https://github.com/darkwebdesign/rust-dotenv\n* Issue Tracker: https://github.com/darkwebdesign/rust-dotenv/issues\n\n## License\n\nDotenv is licensed under the MIT License - see the `LICENSE` file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdarkwebdesign%2Frust-dotenv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdarkwebdesign%2Frust-dotenv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdarkwebdesign%2Frust-dotenv/lists"}