-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Add viper.IsNonDefaultSet
to check if a value is set by config, not default value
#1814
Comments
👋 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, 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:
|
Has the viper team had a chance to give this any thought? |
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:viper/viper.go
Line 1400 in d539b7a
Alternatives Considered
No response
Additional Information
No response
The text was updated successfully, but these errors were encountered: