diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2022-05-30 12:11:14 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2022-05-30 12:11:14 -0400 |
commit | 5cc9d7718fecd0b2b91dcf5acb5d92316c752570 (patch) | |
tree | b32fe8da4ef71b9c53d7203b62b5aade6757d2f7 /pkg/binstruct/marshal.go | |
parent | 703e98f2759148aa2d6ac80f2519ae8e41da3e95 (diff) |
x
Diffstat (limited to 'pkg/binstruct/marshal.go')
-rw-r--r-- | pkg/binstruct/marshal.go | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/pkg/binstruct/marshal.go b/pkg/binstruct/marshal.go index 90f30b6..684d2f3 100644 --- a/pkg/binstruct/marshal.go +++ b/pkg/binstruct/marshal.go @@ -18,10 +18,9 @@ func Marshal(obj any) ([]byte, error) { func MarshalWithoutInterface(obj any) ([]byte, error) { val := reflect.ValueOf(obj) switch val.Kind() { - case reflect.Uint8: - return val.Convert(u8Type).Interface().(Marshaler).MarshalBinary() - case reflect.Int8: - return val.Convert(i8Type).Interface().(Marshaler).MarshalBinary() + case reflect.Uint8, reflect.Int8, reflect.Uint16, reflect.Int16, reflect.Uint32, reflect.Int32, reflect.Uint64, reflect.Int64: + typ := intKind2Type[val.Kind()] + return val.Convert(typ).Interface().(Marshaler).MarshalBinary() case reflect.Ptr: return Marshal(val.Elem().Interface()) case reflect.Array: |