Skip to content

Commit

Permalink
Fixes mergo.Merge skips maps with nil values in it nqd#9
Browse files Browse the repository at this point in the history
  • Loading branch information
davitt committed Sep 27, 2021
1 parent 439a2df commit 4c52e05
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion flat.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func unflatten(flat map[string]interface{}, opts *Options) (nested map[string]in

for k, v := range flat {
temp := uf(k, v, opts).(map[string]interface{})
err = mergo.Merge(&nested, temp)
err = mergo.Merge(&nested, temp, func(c *mergo.Config) {c.Overwrite = true})
if err != nil {
return
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ module github.com/nqd/flat

go 1.12

require github.com/imdario/mergo v0.3.6
require github.com/imdario/mergo v0.3.12
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
github.com/imdario/mergo v0.3.6 h1:xTNEAn+kxVO7dTZGu0CegyqKZmoWFI0rF8UxjlB2d28=
github.com/imdario/mergo v0.3.6/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU=
github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

0 comments on commit 4c52e05

Please sign in to comment.