Preflight Checklist
Viper Version
1.18.2
Go Version
1.24.6
Config Source
Files
Format
YAML
Repl.it link
No response
Code reproducing the issue
v := viper.NewWithOptions(viper.KeyDelimiter("<SEPARATOR>"))
Expected Behavior
For map values, they will come in blank because of this line:
|
path = strings.Split(lcaseKey, v.keyDelim) |
This code:
path = strings.Split(lcaseKey, v.keyDelim)
should be
path = strings.Split(lcaseKey, strings.ToLower(v.keyDelim)
I don't think I can open a PR against this repo, or I would just send one. Hopefully this is a simple enough patch to describe here.
Actual Behavior
When I read the config file, and I read this:
I don't get a value for severity from v.Unmarshal, because the split is splitting a lowercased string on a possibly-upper-case keyDelim.
See fix above: call strings.ToLower() on the v.keyDelim before splitting on it.
Steps To Reproduce
No response
Additional Information
I need to support map-valued config keys whose subkeys contain dots even though that map is flat.
My workaround is that I'm using · (U+00B7) as a keyDelim instead of <SEPARATOR>. Because my map is flat, I just need something that nobody will ever actually want to use.
Preflight Checklist
Viper Version
1.18.2
Go Version
1.24.6
Config Source
Files
Format
YAML
Repl.it link
No response
Code reproducing the issue
Expected Behavior
For map values, they will come in blank because of this line:
viper/viper.go
Line 1153 in 0525738
This code:
should be
I don't think I can open a PR against this repo, or I would just send one. Hopefully this is a simple enough patch to describe here.
Actual Behavior
When I read the config file, and I read this:
I don't get a value for
severityfrom v.Unmarshal, because the split is splitting a lowercased string on a possibly-upper-case keyDelim.See fix above: call
strings.ToLower()on thev.keyDelimbefore splitting on it.Steps To Reproduce
No response
Additional Information
I need to support map-valued config keys whose subkeys contain dots even though that map is flat.
My workaround is that I'm using
·(U+00B7) as a keyDelim instead of<SEPARATOR>. Because my map is flat, I just need something that nobody will ever actually want to use.