summaryrefslogtreecommitdiff
path: root/pkg/binstruct/unmarshal.go
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2022-05-30 12:11:14 -0400
committerLuke Shumaker <lukeshu@lukeshu.com>2022-05-30 12:11:14 -0400
commit5cc9d7718fecd0b2b91dcf5acb5d92316c752570 (patch)
treeb32fe8da4ef71b9c53d7203b62b5aade6757d2f7 /pkg/binstruct/unmarshal.go
parent703e98f2759148aa2d6ac80f2519ae8e41da3e95 (diff)
x
Diffstat (limited to 'pkg/binstruct/unmarshal.go')
-rw-r--r--pkg/binstruct/unmarshal.go10
1 files changed, 3 insertions, 7 deletions
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