mirror of
https://github.com/spf13/viper
synced 2024-12-22 11:37:02 +00:00
refactor: move all settings code to a getter
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
This commit is contained in:
parent
c4dcd31f68
commit
6ea31ae4ca
1 changed files with 5 additions and 1 deletions
6
viper.go
6
viper.go
|
@ -2098,9 +2098,13 @@ outer:
|
|||
func AllSettings() map[string]any { return v.AllSettings() }
|
||||
|
||||
func (v *Viper) AllSettings() map[string]any {
|
||||
return v.getSettings(v.AllKeys())
|
||||
}
|
||||
|
||||
func (v *Viper) getSettings(keys []string) map[string]any {
|
||||
m := map[string]any{}
|
||||
// start from the list of keys, and construct the map one value at a time
|
||||
for _, k := range v.AllKeys() {
|
||||
for _, k := range keys {
|
||||
value := v.Get(k)
|
||||
if value == nil {
|
||||
// should not happen, since AllKeys() returns only keys holding a value,
|
||||
|
|
Loading…
Reference in a new issue