Nice to avoid copying large value types.
if dV.Kind() == reflect.Array && !dV.CanAddr() {
panic(fmt.Sprintf("dest not addressable: %T", dest))
}
+ if sV.Kind() == reflect.Ptr {
+ sV = sV.Elem()
+ }
if sV.Kind() == reflect.String {
sV = sV.Convert(reflect.SliceOf(dV.Type().Elem()))
}
}()
CopyExact(&arr, nil)
}
+
+func TestCopySrcPtr(t *testing.T) {
+ var bigDst [1024]byte
+ var bigSrc [1024]byte = [1024]byte{'h', 'i'}
+ CopyExact(&bigDst, &bigSrc)
+ if !bytes.Equal(bigDst[:], bigSrc[:]) {
+ t.FailNow()
+ }
+}