Open haoming29 opened 5 months ago
👋 Thanks for reporting!
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 have a couple minutes, please take some time and share your thoughts: https://forms.gle/R6faU74qPRPAzchZ9
📣 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:
https://twitter.com/sagikazarmark/status/1306904078967074816
Thank you! ❤️
@haoming29 can you give an example where this is useful?
Viper is moving away from this direction, so even if we add it now, it may have to be removed later, so I'd like to understand the use case for such a feature.
Thanks!
The software stack @Haoming29 use viper in would benefit from knowing this for a few reasons:
Preflight Checklist
Problem Description
Currently,
viper.IsSet
returnstrue
if the key has a default value. However, it would be useful to know if a value is set by the user via config/env/etc.Proposed Solution
Have a new method to check if a key is set by config/env other than the default value. It seems that viper keeps the default values of keys in
v.defaults
map: https://github.com/spf13/viper/blob/d539b7a2462e595e8e97e0f7eaeb2ea2933f5555/viper.go#L1400 so it's doable to implement this feature.Alternatives Considered
No response
Additional Information
No response