You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched the issue tracker for an issue that matches the one I want to file, without success.
Problem Description
When you want to use environment variables as a source of configuration you need to bind each item explicitly or have another source of configuration to populate the store and then be able to use AutomaticEnv to override the values from the environment variables.
So this piece of code is not doing what I'd expect:
P.S. This feels like an issue that should've been brought up many times but couldn't find another issue like this so I apologize in-advance if it's redundant.
Proposed Solution
To solve the issue I wrote this function and it could be a part of Viper itself.
So if Viper had a method like this it'd be so easy to tell it to bind all configurations defined by my Config struct.
viper.BindEnvByStruct(config{})
// orviper.BindAllEnv(config{})
// orviper.AutomaticEnv(config{}) // with changing the signature to `func AutomaticEnv(s ...interface{}) error` which I'd assume you wouldn't like since it could be considered a breaking change.
If you're up for it I'd like to make a PR for it.
Alternatives Considered
No response
Additional Information
No response
The text was updated successfully, but these errors were encountered:
A maintainer will take a look at your issue shortly. 👀
In the meantime: We are working on Viper v2 and we would love to hear your thoughts about what you like or don't like about Viper, so we can improve or fix those issues.
📣 If you've already given us your feedback, you can still help by spreading the news,
either by sharing the above link or telling people about this on Twitter:
@mehdy I have the same issue as you. Your method seems similar to the one mentioned in #584. Viper has implemented BindStruct in #1429 but didn't turn on for backward compatibility(#1706). For your case, you can turn on viper_bind_struct as the following command:
Preflight Checklist
Problem Description
When you want to use environment variables as a source of configuration you need to bind each item explicitly or have another source of configuration to populate the store and then be able to use
AutomaticEnv
to override the values from the environment variables.So this piece of code is not doing what I'd expect:
P.S. This feels like an issue that should've been brought up many times but couldn't find another issue like this so I apologize in-advance if it's redundant.
Proposed Solution
To solve the issue I wrote this function and it could be a part of Viper itself.
So if Viper had a method like this it'd be so easy to tell it to bind all configurations defined by my Config struct.
If you're up for it I'd like to make a PR for it.
Alternatives Considered
No response
Additional Information
No response
The text was updated successfully, but these errors were encountered: