diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2022-05-10 04:46:06 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2022-05-10 04:46:06 -0600 |
commit | 2744e0700ca6fe956f569d47010fd4e693fedcfa (patch) | |
tree | 17cc6eb920ece3700a10a86ed465d4a0947d32c4 /pkg/binstruct/l1.go | |
parent | a16049ef805c0c08b90885a5b7dfea7f74e51c5f (diff) |
more
Diffstat (limited to 'pkg/binstruct/l1.go')
-rw-r--r-- | pkg/binstruct/l1.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/pkg/binstruct/l1.go b/pkg/binstruct/l1.go index c535d2e..e76e7d0 100644 --- a/pkg/binstruct/l1.go +++ b/pkg/binstruct/l1.go @@ -136,10 +136,10 @@ func genHandler(typ reflect.Type) (handler, error) { } return primitive{ unmarshal: func(dat []byte) interface{} { - val := reflect.Zero(typ) + val := reflect.New(typ).Elem() for i := 0; i < typ.Len(); i++ { - fmt.Printf("%v[%d]: %v\n", typ, i, val.Index(i)) - val.Index(i).Set(reflect.ValueOf(inner.Unmarshal(dat[i*int(inner.Size()):]))) + fieldVal := inner.Unmarshal(dat[i*int(inner.Size()):]) + val.Index(i).Set(reflect.ValueOf(fieldVal).Convert(typ.Elem())) } return val.Interface() }, |