Closed dshulyak closed 2 years ago
If we define alias to a byte array as:
type Alias [20]byte type Example struct { Field []Alias }
It will not be respected by generator, and we will get [][20]byte in the generated code.
[][20]byte
For a work around i used:
diff --git a/sszgen/unmarshal.go b/sszgen/unmarshal.go index 836fd3c..3222b6b 100644 --- a/sszgen/unmarshal.go +++ b/sszgen/unmarshal.go @@ -338,6 +338,9 @@ func (v *Value) createSlice() string { if v.c { return "" } + if len(v.e.obj) > 0 { + return fmt.Sprintf("::.%s = make([]%v, %s)", v.name, v.e.objRef(), size) + } if v.e.c { return fmt.Sprintf("::.%s = make([][%d]byte, %s)", v.name, v.e.s, size) }
If we define alias to a byte array as:
It will not be respected by generator, and we will get
[][20]byte
in the generated code.For a work around i used: