#env-file #env #dotenv #environment #compile-time #settings #proc-macro

macro load-dotenv

This is a small procedural macro to load your .env file at compile time

3 releases

0.1.2 Jan 4, 2021
0.1.1 Feb 15, 2019
0.1.0 Feb 15, 2019

#53 in #dotenv

Download history 64/week @ 2023-12-18 51/week @ 2023-12-25 18/week @ 2024-01-01 73/week @ 2024-01-08 108/week @ 2024-01-15 56/week @ 2024-01-22 33/week @ 2024-01-29 45/week @ 2024-02-05 61/week @ 2024-02-12 93/week @ 2024-02-19 112/week @ 2024-02-26 91/week @ 2024-03-04 126/week @ 2024-03-11 103/week @ 2024-03-18 96/week @ 2024-03-25 153/week @ 2024-04-01

495 downloads per month

MIT license

4KB

load-dotenv

This is a small procedural macro to load your .env file at compile time. That way you can use std::env! to load environment variables and fail the build if a variable is missing.

All it does is call the dotenv crate.

Example

.env file:

KEY=value

Rust:

use load_dotenv::load_dotenv;

load_dotenv!();

fn main() {
    assert_eq!("value", env!("KEY"));
}

License: MIT


lib.rs:

This is a small procedural macro to load your .env file at compile time. That way you can use std::env! to load environment variables and fail the build if a variable is missing.

All it does is call the dotenv crate.

Example

.env file:

KEY=value

Rust:

use load_dotenv::load_dotenv;

load_dotenv!();

fn main() {
    assert_eq!("value", env!("KEY"));
}

Dependencies

~34KB