-
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
Binding flags and unmarshalling to nested structures #190
Comments
PR #195 should have fixed this issue. |
I'm not sure what is actually happening is what you hope for. If you dump out the resulting config with
PS: Yep, I just spent some ungodly amount of time trying to bind nested objects too. Apparently it is not supported. edit: Just saw that PR #195 hasn't been merged to master yet. So there is still hope :) |
Indeed, the current version of That's the purpose of commit |
@benoitmasson: Actually did pull your patch, works beautifully for me as well. Thanks a bundle! |
Fixes #71, #93, #158, #168, #209, #141, #160, #162, #190 * Fixed: indentation in comment * Fixed: Get() returns nil when nested element not found * Fixed: insensitiviseMaps() made recursive so that nested keys are lowercased * Fixed: order of expected<=>actual in assert.Equal() statements * Fixed: find() looks into "overrides" first * Fixed: TestBindPFlags() to use a new Viper instance * Fixed: removed extra aliases from display in Debug() * Added: test for checking precedence of dot-containing keys. * Fixed: Set() and SetDefault() insert nested values * Added: tests for overriding nested values * Changed: AllKeys() includes all keys / AllSettings() includes overridden nested values * Added: test for shadowed nested key * Fixed: properties parsing generates nested maps * Fixed: Get() and IsSet() work correctly on nested values * Changed: modifier README.md to reflect changes
Fixed by #195 |
Is there still a similar issue with use of UnmarhsalKey?
It always produces the value from the config file; the command line override never takes effect.
|
I have the same issue. The command line don't override the value. The struct always use config file value instead of command line. |
Hi,
I've run into a small issue when overriding a configuration value with a command-line flag: after unmarshalling to a struct, fields in nested sub-structures are not updated, while level-1 fields are.
For example, this piece of code:
associated with this configuration file:
produces the following output:
The last
nested.test2
value is correct when usingviper.GetInt("nested.test2")
, but it is not in the struct, while both values are correct fortest1
.This may be related to Issue #168, where it also appears that the nested struct is not updated when the internal map changes.
The text was updated successfully, but these errors were encountered: