8 func CopyExact(dest interface{}, src interface{}) {
9 dV := reflect.ValueOf(dest)
10 sV := reflect.ValueOf(src)
11 if dV.Kind() == reflect.Ptr {
14 if dV.Kind() == reflect.Array && !dV.CanAddr() {
15 panic(fmt.Sprintf("dest not addressable: %T", dest))
17 if sV.Kind() == reflect.String {
18 sV = sV.Convert(reflect.SliceOf(dV.Type().Elem()))
21 panic("invalid source, probably nil")
23 if dV.Len() != sV.Len() {
24 panic(fmt.Sprintf("dest len (%d) != src len (%d)", dV.Len(), sV.Len()))
26 if dV.Len() != reflect.Copy(dV, sV) {