-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Overriding files #41
Comments
I've done this as a work around. This is only part of the table you've referenced. fn load_environment_variables() {
let environment = env::var("RUST_ENV").unwrap_or_else(|_| "".to_string());
if environment == "development" {
dotenv::from_filename(".env.development").ok();
}
if environment == "test" {
dotenv::from_filename(".env.test").ok();
}
if environment == "production" {
dotenv::from_filename(".env.production").ok();
}
dotenv::dotenv().ok();
} |
I've done this in one of my projects. (Not tested) #[derive(Deserialize, Debug, Clone)]
pub struct Config {
auth_url: String,
client_id: String,
scope: String,
redirect_uri: String,
}
fn load_config() -> Result<Config, envy::Error> {
let profile = if cfg!(test) {
"test"
} else if cfg!(debug_assertions) {
"development"
} else {
"production"
};
dotenv::from_filename(format!(".env.{}.local", profile)).ok();
dotenv::from_filename(".env.local").ok();
dotenv::from_filename(format!(".env.{}", profile)).ok();
dotenv::dotenv().ok();
envy::from_env::<Config>()
} I've also used envy -> https://github.com/softprops/envy |
I have my implementation here. |
Nice workarounds! I was looking for this just now. But I wonder why this is not part of |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Coming from https://github.com/bkeepers/dotenv, is there a way to use these files too: https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use?
The text was updated successfully, but these errors were encountered: