| Crates.io | compile-dotenv |
| lib.rs | compile-dotenv |
| version | 0.1.0 |
| created_at | 2025-03-27 13:46:44.280515+00 |
| updated_at | 2025-03-27 13:46:44.280515+00 |
| description | Add environment variables defined in the environment or in a .env file at compile time. |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1607957 |
| size | 8,860 |
Add environment variables defined in the environment or in a .env file at compile time.
The compile-dotenv library helps you manage environment variables by allowing you to inject them at compile time.
This can be particularly useful for configuring applications across different environments without hardcoding sensitive or environment-specific data.
.env file.To add compile-dotenv to your project, add the following line to your Cargo.toml file:
[dependencies]
compile-dotenv = "0.1.0"
Here is a simple example of how to use compile-dotenv in your Rust project:
Create a .env file in the root of your project:
SENTRY_DSN=https://examplePublicKey@o0.ingest.sentry.io/0
Use compile-dotenv to instantiate a Sentry guard in your main.rs or any other part of your application:
use compile_dotenv::compile_env;
fn main() {
let _guard = sentry::init(compile_env!("SENTRY_DSN"));
// ...
}