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

Method Set

viper.go:1501–1512  ·  view source on GitHub ↗
(key string, value any)

Source from the content-addressed store, hash-verified

1499func Set(key string, value any) { v.Set(key, value) }
1500
1501func (v *Viper) Set(key string, value any) {
1502 // If alias passed in, then set the proper override
1503 key = v.realKey(strings.ToLower(key))
1504 value = toCaseInsensitiveValue(value)
1505
1506 path := strings.Split(key, v.keyDelim)
1507 lastKey := strings.ToLower(path[len(path)-1])
1508 deepestMap := deepSearch(v.override, path[0:len(path)-1])
1509
1510 // set innermost value
1511 deepestMap[lastKey] = value
1512}
1513
1514// ReadInConfig will discover and load the configuration file from disk
1515// and key/value stores, searching in one of the defined paths.

Callers 5

TestNestedOverridesFunction · 0.95
overrideFromLayerFunction · 0.45
SetFunction · 0.45
TestBindFlagValueSetFunction · 0.45
TestBindFlagValueFunction · 0.45

Calls 3

realKeyMethod · 0.95
toCaseInsensitiveValueFunction · 0.85
deepSearchFunction · 0.85

Tested by 4

TestNestedOverridesFunction · 0.76
overrideFromLayerFunction · 0.36
TestBindFlagValueSetFunction · 0.36
TestBindFlagValueFunction · 0.36