summaryrefslogtreecommitdiff
path: root/pkg/binstruct/l1.go
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2022-05-10 04:46:06 -0600
committerLuke Shumaker <lukeshu@lukeshu.com>2022-05-10 04:46:06 -0600
commit2744e0700ca6fe956f569d47010fd4e693fedcfa (patch)
tree17cc6eb920ece3700a10a86ed465d4a0947d32c4 /pkg/binstruct/l1.go
parenta16049ef805c0c08b90885a5b7dfea7f74e51c5f (diff)
more
Diffstat (limited to 'pkg/binstruct/l1.go')
-rw-r--r--pkg/binstruct/l1.go6
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()
},