reading struct fields explicitly

This commit is contained in:
Pavel Merzlyakov 2023-06-08 09:55:03 +03:00
parent b079835cb3
commit 1b4defc4f7
1 changed files with 7 additions and 1 deletions

View File

@ -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' %}