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

Method isPathShadowedInAutoEnv

viper.go:671–680  ·  view source on GitHub ↗

isPathShadowedInAutoEnv makes sure the given path is not shadowed somewhere in the environment, when automatic env is on. e.g., if "foo.bar" has a value in the environment, it “shadows” "foo.bar.baz" in a lower-priority map

(path []string)

Source from the content-addressed store, hash-verified

669//
670// "foo.bar.baz" in a lower-priority map
671func (v *Viper) isPathShadowedInAutoEnv(path []string) string {
672 var parentKey string
673 for i := 1; i < len(path); i++ {
674 parentKey = strings.Join(path[0:i], v.keyDelim)
675 if _, ok := v.getEnv(v.mergeWithEnvPrefix(parentKey)); ok {
676 return parentKey
677 }
678 }
679 return ""
680}
681
682// SetTypeByDefaultValue enables or disables the inference of a key value's
683// type when the Get function is used based upon a key's default value as

Callers 1

findMethod · 0.95

Calls 2

getEnvMethod · 0.95
mergeWithEnvPrefixMethod · 0.95

Tested by

no test coverage detected