Skip to content

Commit

Permalink
initialize destination map if nil
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentcr committed May 24, 2015
1 parent 2fcac99 commit bb806be
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ func deepMerge(dst, src reflect.Value, visited map[uintptr]*visit, depth int, ov
}
}
if !isEmptyValue(srcElement) && (overwrite || (!dstElement.IsValid() || isEmptyValue(dst))) {
if dst.IsNil() {
dst.Set(reflect.MakeMap(dst.Type()))
}
dst.SetMapIndex(key, srcElement)
}
}
Expand Down

0 comments on commit bb806be

Please sign in to comment.