Changed logic to typeswitch and added comments.
And also added my name to contrib list as promised before.
This commit is contained in:
parent
8aab8c6fb2
commit
fcf9302ae1
|
@ -6,3 +6,4 @@ Dusty Wilson
|
|||
Marek Majkowski
|
||||
Peter van Dijk
|
||||
Omri Bahumi
|
||||
Alex Sergeyev
|
||||
|
|
14
msg.go
14
msg.go
|
@ -577,13 +577,16 @@ func packStructValue(val reflect.Value, msg []byte, off int, compression map[str
|
|||
default:
|
||||
return lenmsg, &Error{err: "bad kind packing"}
|
||||
case reflect.Interface:
|
||||
if data, ok := fv.Interface().(PrivateRdata); ok {
|
||||
// PrivateRR is the only RR implementation that has interface field.
|
||||
// therefore it's expected that this interface would be PrivateRdata
|
||||
switch data := fv.Interface().(type) {
|
||||
case PrivateRdata:
|
||||
n, err := data.WriteByteSlice(msg[off:])
|
||||
if err != nil {
|
||||
return lenmsg, err
|
||||
}
|
||||
off += n
|
||||
} else {
|
||||
default:
|
||||
return lenmsg, &Error{err: "bad kind interface packing"}
|
||||
}
|
||||
case reflect.Slice:
|
||||
|
@ -880,13 +883,16 @@ func unpackStructValue(val reflect.Value, msg []byte, off int) (off1 int, err er
|
|||
default:
|
||||
return lenmsg, &Error{err: "bad kind unpacking"}
|
||||
case reflect.Interface:
|
||||
if data, ok := fv.Interface().(PrivateRdata); ok {
|
||||
// PrivateRR is the only RR implementation that has interface field.
|
||||
// therefore it's expected that this interface would be PrivateRdata
|
||||
switch data := fv.Interface().(type) {
|
||||
case PrivateRdata:
|
||||
n, err := data.ParseByteSlice(msg[off:rdend])
|
||||
if err != nil {
|
||||
return lenmsg, err
|
||||
}
|
||||
off += n
|
||||
} else {
|
||||
default:
|
||||
return lenmsg, &Error{err: "bad kind interface unpacking"}
|
||||
}
|
||||
case reflect.Slice:
|
||||
|
|
Loading…
Reference in New Issue