From 1b4defc4f7f8cf351525061c585b2b9a686b4a3d Mon Sep 17 00:00:00 2001 From: Pavel Merzlyakov Date: Thu, 8 Jun 2023 09:55:03 +0300 Subject: [PATCH] reading struct fields explicitly --- tpl/macros_struct.twig | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tpl/macros_struct.twig b/tpl/macros_struct.twig index 61476c5..557e41f 100644 --- a/tpl/macros_struct.twig +++ b/tpl/macros_struct.twig @@ -729,13 +729,19 @@ func (s *{{ name|default(o.name) }}) readFields(reader meta.Reader) error { return errors.Errorf("bad enum value `%d` for `{{ alias }}`", {{ fname }}) } {% elseif type is struct %} - if err := {{ fname }}.Read(reader); err != nil { + if err := reader.BeginContainer("{{ alias }}"); err != nil { + return err + } + if err := {{ fname }}.ReadFields(reader); err != nil { {% if optional %} return nil {% else %} return err {% endif %} } + if err := reader.EndContainer(); err != nil { + return err + } {% elseif type is array %} {% set name = fname|split('.')|last %} {% set size_var = name|lcfirst ~ 'Size' %}