update dependencies

This commit is contained in:
Cory Bennett
2017-09-06 11:35:00 -07:00
parent 9453179251
commit aa876cd588
308 changed files with 46154 additions and 33733 deletions
+4
View File
@@ -33,6 +33,10 @@ func Copy(toValue interface{}, fromValue interface{}) (err error) {
fromType := indirectType(from.Type())
toType := indirectType(to.Type())
if fromType.Kind() != reflect.Struct || toType.Kind() != reflect.Struct {
return
}
if to.Kind() == reflect.Slice {
isSlice = true
if from.Kind() == reflect.Slice {
+26 -3
View File
@@ -1,9 +1,9 @@
package copier_test
import (
"fmt"
"reflect"
"testing"
"time"
"github.com/jinzhu/copier"
)
@@ -49,8 +49,6 @@ func checkEmployee(employee Employee, user User, t *testing.T, testCase string)
t.Errorf("%v: Age haven't been copied correctly.", testCase)
}
if user.FakeAge != nil && employee.FakeAge != int(*user.FakeAge) {
fmt.Println(employee.FakeAge)
fmt.Println(*user.FakeAge)
t.Errorf("%v: FakeAge haven't been copied correctly.", testCase)
}
if employee.DoubleAge != user.DoubleAge() {
@@ -187,3 +185,28 @@ func TestEmbedded(t *testing.T) {
t.Error("Embedded fields not copied")
}
}
type structSameName1 struct {
A string
B int64
C time.Time
}
type structSameName2 struct {
A string
B time.Time
C int64
}
func TestCopyFieldsWithSameNameButDifferentTypes(t *testing.T) {
obj1 := structSameName1{A: "123", B: 2, C: time.Now()}
obj2 := &structSameName2{}
err := copier.Copy(obj2, &obj1)
if err != nil {
t.Error("Should not raise error")
}
if obj2.A != obj1.A {
t.Errorf("Field A should be copied")
}
}