Skip to content

Commit

Permalink
Issue #123 fixed (again)
Browse files Browse the repository at this point in the history
  • Loading branch information
darccio committed Jul 17, 2020
1 parent 87eedcd commit 60f2262
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 0 additions & 4 deletions issue104_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package mergo

import (
"fmt"
"reflect"
"testing"
)
Expand All @@ -19,8 +18,6 @@ func StructToRecord(in interface{}) *Record {
for i := 0; i < typ.NumField(); i++ {
field := typ.Field(i)
dbFieldName := field.Tag.Get("db")

fmt.Printf("%d %v, tags: %v\n", i, field.Name, dbFieldName)
if dbFieldName != "" {
rec.Mapping[field.Name] = dbFieldName
}
Expand All @@ -41,7 +38,6 @@ func TestStructToRecord(t *testing.T) {
}
a := A{Name: "David", CIDR: "10.0.0.0/8"}
rec := StructToRecord(a)
fmt.Printf("rec: %+v\n", rec)
if len(rec.Mapping) < 2 {
t.Fatalf("struct to record failed, no mapping, struct missing tags?, rec: %+v, a: %+v ", rec, a)
}
Expand Down
3 changes: 3 additions & 0 deletions merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ func deepMerge(dst, src reflect.Value, visited map[uintptr]*visit, depth int, co
switch srcElement.Kind() {
case reflect.Chan, reflect.Func, reflect.Map, reflect.Interface, reflect.Slice:
if srcElement.IsNil() {
if overwrite {
dst.SetMapIndex(key, srcElement)
}
continue
}
fallthrough
Expand Down

0 comments on commit 60f2262

Please sign in to comment.