#env-file #dotenv #env #environment #compile-time #settings #config

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

#60 in #dotenv

Download history 82/week @ 2024-07-22 116/week @ 2024-07-29 69/week @ 2024-08-05 111/week @ 2024-08-12 83/week @ 2024-08-19 58/week @ 2024-08-26 88/week @ 2024-09-02 71/week @ 2024-09-09 84/week @ 2024-09-16 96/week @ 2024-09-23 67/week @ 2024-09-30 3/week @ 2024-10-07 55/week @ 2024-10-14 81/week @ 2024-10-21 81/week @ 2024-10-28 102/week @ 2024-11-04

319 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