-
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
Nested .
separated flags with common prefix not working with pflag in Viper >= 1.18.0
#1922
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! ❤️ |
I am also facing the same issue. I found a pattern where in two flags registered with same common prefix, then it is returning empty for the child flags. For example:
|
.
separated flags not working with pflag in Viper 1.18.0
.
separated flags with common prefix not working with pflag in Viper >= 1.18.0
Thanks, Akshay, for noticing this pattern. I see the same pattern now. I initially thought it was specific to |
Maybe read this part would be helpful. "gateway.endpoint.v1" was Here is the source code cause this 'problem'. Pay attention to the Lines 1202 to 1204 in 8b223a4
Lines 633 to 675 in 8b223a4
It should not be treated as a bug. |
But I do think there should be some error when we use Pflag.String to set those keys, telling us that we should not use shadowed key. |
Preflight Checklist
Viper Version
1.18.0
Go Version
1.22.6
Config Source
Flags
Format
Other (specify below)
Repl.it link
No response
Code reproducing the issue
Expected Behavior
it should print:
Actual Behavior
in v1.17.0
it is working as expected
returning output as
Steps To Reproduce
Additional Information
Updated:
I can see it is working with another nested flags like
_ = pflag.String("a.b.c.d.v1", "some/path/abc", "endpoint of gateway server v4")
but i am wondering what is the special with key
gateway.endpoint.*
The text was updated successfully, but these errors were encountered: