MCPcopy
hub / github.com/spf13/viper / isPathShadowedInDeepMap

Method isPathShadowedInDeepMap

viper.go:617–636  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

615//
616// "foo.bar.baz" in a lower-priority map
617func (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.

Callers 1

findMethod · 0.95

Calls 1

searchMapMethod · 0.95

Tested by

no test coverage detected