]> Sergey Matveev's repositories - btrtrc.git/blobdiff - util/copy.go
util/CopyExact: Test copying from interfaces and nil
[btrtrc.git] / util / copy.go
index 793a99cd951c832922dabd474a83e3c9080dd977..fda4cffc39906c68bf0881a076d33ae8f73a3faf 100644 (file)
@@ -17,6 +17,9 @@ func CopyExact(dest interface{}, src interface{}) {
        if sV.Kind() == reflect.String {
                sV = sV.Convert(reflect.SliceOf(dV.Type().Elem()))
        }
+       if !sV.IsValid() {
+               panic("invalid source, probably nil")
+       }
        if dV.Len() != sV.Len() {
                panic(fmt.Sprintf("dest len (%d) != src len (%d)", dV.Len(), sV.Len()))
        }