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

Method AllKeys

viper.go:1888–1905  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1886func AllKeys() []string { return v.AllKeys() }
1887
1888func (v *Viper) AllKeys() []string {
1889 m := map[string]bool{}
1890 // add all paths, by order of descending priority to ensure correct shadowing
1891 m = v.flattenAndMergeMap(m, castMapStringToMapInterface(v.aliases), "")
1892 m = v.flattenAndMergeMap(m, v.override, "")
1893 m = v.mergeFlatMap(m, castMapFlagToMapInterface(v.pflags))
1894 m = v.mergeFlatMap(m, castMapStringSliceToMapInterface(v.env))
1895 m = v.flattenAndMergeMap(m, v.config, "")
1896 m = v.flattenAndMergeMap(m, v.kvstore, "")
1897 m = v.flattenAndMergeMap(m, v.defaults, "")
1898
1899 // convert set of paths to list
1900 a := make([]string, 0, len(m))
1901 for x := range m {
1902 a = append(a, x)
1903 }
1904 return a
1905}
1906
1907// flattenAndMergeMap recursively flattens the given map into a map[string]bool
1908// of key paths (used as a set, easier to manipulate than a []string):

Callers 7

UnmarshalMethod · 0.95
UnmarshalExactMethod · 0.95
AllSettingsMethod · 0.95
TestAllKeysFunction · 0.80
TestAllKeysWithEnvFunction · 0.80
TestReadConfigFunction · 0.80
AllKeysFunction · 0.80

Calls 5

flattenAndMergeMapMethod · 0.95
mergeFlatMapMethod · 0.95

Tested by 3

TestAllKeysFunction · 0.64
TestAllKeysWithEnvFunction · 0.64
TestReadConfigFunction · 0.64