From 5cc9d7718fecd0b2b91dcf5acb5d92316c752570 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 30 May 2022 12:11:14 -0400 Subject: x --- pkg/binstruct/unmarshal.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'pkg/binstruct/unmarshal.go') diff --git a/pkg/binstruct/unmarshal.go b/pkg/binstruct/unmarshal.go index ca2f4b2..1959d45 100644 --- a/pkg/binstruct/unmarshal.go +++ b/pkg/binstruct/unmarshal.go @@ -24,13 +24,9 @@ func UnmarshalWithoutInterface(dat []byte, dstPtr any) (int, error) { dst := _dstPtr.Elem() switch dst.Kind() { - case reflect.Uint8: - newDstPtr := reflect.New(u8Type) - n, err := Unmarshal(dat, newDstPtr.Interface()) - dst.Set(newDstPtr.Elem().Convert(dst.Type())) - return n, err - case reflect.Int8: - newDstPtr := reflect.New(i8Type) + case reflect.Uint8, reflect.Int8, reflect.Uint16, reflect.Int16, reflect.Uint32, reflect.Int32, reflect.Uint64, reflect.Int64: + typ := intKind2Type[dst.Kind()] + newDstPtr := reflect.New(typ) n, err := Unmarshal(dat, newDstPtr.Interface()) dst.Set(newDstPtr.Elem().Convert(dst.Type())) return n, err -- cgit v1.2.3-2-g168b