isPathShadowedInDeepMap makes sure the given path is not shadowed somewhere on its path in the map. e.g., if "foo.bar" has a value in the given map, it “shadows” "foo.bar.baz" in a lower-priority map
(path []string, m map[string]any)
| 615 | // |
| 616 | // "foo.bar.baz" in a lower-priority map |
| 617 | func (v *Viper) isPathShadowedInDeepMap(path []string, m map[string]any) string { |
| 618 | var parentVal any |
| 619 | for i := 1; i < len(path); i++ { |
| 620 | parentVal = v.searchMap(m, path[0:i]) |
| 621 | if parentVal == nil { |
| 622 | // not found, no need to add more path elements |
| 623 | return "" |
| 624 | } |
| 625 | switch parentVal.(type) { |
| 626 | case map[any]any: |
| 627 | continue |
| 628 | case map[string]any: |
| 629 | continue |
| 630 | default: |
| 631 | // parentVal is a regular value which shadows "path" |
| 632 | return strings.Join(path[0:i], v.keyDelim) |
| 633 | } |
| 634 | } |
| 635 | return "" |
| 636 | } |
| 637 | |
| 638 | // isPathShadowedInFlatMap makes sure the given path is not shadowed somewhere |
| 639 | // in a sub-path of the map. |