From 2744e0700ca6fe956f569d47010fd4e693fedcfa Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 10 May 2022 04:46:06 -0600 Subject: more --- pkg/binstruct/l1.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'pkg/binstruct/l1.go') 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() }, -- cgit v1.2.3-2-g168b