use .env
as config file and parse environments to config struct.
```rust use dotenv_config::EnvConfig;
struct Config {
#[envconfig(default = "192.168.2.1")]
serveraddr: String,
servermode: bool,
#[envconfig(name = "ZINCFOO", default = true)]
foo: bool,
#[envconfig(name = "ZINC_BAR", default = 123456)]
bar: Option
fn main() { let cfg = Config::init().unwrap(); println!("{:#?}", cfg); } ```
you can use macro attribute set field attribute
.env
file config it.
ZINC_FOO=false
ZINC_BAR=8787878
default load environment key is: structName_fieldName
do UpperSnake, like above struct, default config key is:
CONFIG_SERVER_ADDR
CONFIG_SERVER_MODE
ZINC_FOO
ZINC_BAR