Skip to content

Commit

Permalink
fix: retry set value error on load yaml v2 data
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Aug 9, 2022
1 parent 168ab35 commit 9764bbd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions write.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ func (c *Config) Set(key string, val interface{}, setByPath ...bool) (err error)
}

switch typeData := item.(type) {
case map[interface{}]interface{}: // from yaml
dstItem := make(map[string]interface{})
case map[interface{}]interface{}: // from yaml.v2
dstItem := make(map[interface{}]interface{}, len(typeData))
for k, v := range typeData {
sk := fmt.Sprintf("%v", k)
dstItem[sk] = v
Expand All @@ -90,7 +90,7 @@ func (c *Config) Set(key string, val interface{}, setByPath ...bool) (err error)
}

c.data[topK] = dstItem
case map[string]interface{}: // from json,toml
case map[string]interface{}: // from json,toml,yaml.v3
// create a new item for the topK
newItem := buildValueByPath(paths, val)
// merge new item to old item
Expand Down

0 comments on commit 9764bbd

Please sign in to comment.