Fix tests with nil check via reflection

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2020-08-18 12:14:47 +03:00 committed by Stanislav Bogatyrev
parent 1592151621
commit c3604d00f0

View file

@ -9,6 +9,7 @@ package proto
import ( import (
"encoding/binary" "encoding/binary"
"math/bits" "math/bits"
"reflect"
) )
type ( type (
@ -305,7 +306,7 @@ func NestedStructurePrefix(field int64) (prefix uint64, ln int) {
} }
func NestedStructureMarshal(field int64, buf []byte, v stableMarshaller) (int, error) { func NestedStructureMarshal(field int64, buf []byte, v stableMarshaller) (int, error) {
if v == nil { if v == nil || reflect.ValueOf(v).IsNil() {
return 0, nil return 0, nil
} }
@ -324,7 +325,7 @@ func NestedStructureMarshal(field int64, buf []byte, v stableMarshaller) (int, e
} }
func NestedStructureSize(field int64, v stableMarshaller) (size int) { func NestedStructureSize(field int64, v stableMarshaller) (size int) {
if v == nil { if v == nil || reflect.ValueOf(v).IsNil() {
return 0 return 0
} }