Skip to content

Commit

Permalink
refactor: move all settings code to a getter
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
  • Loading branch information
sagikazarmark committed Dec 6, 2023
1 parent c4dcd31 commit 6ea31ae
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion viper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 6ea31ae

Please sign in to comment.