diff --git a/tpl/macros_struct.twig b/tpl/macros_struct.twig index 3c931a6..4800962 100644 --- a/tpl/macros_struct.twig +++ b/tpl/macros_struct.twig @@ -603,10 +603,12 @@ func (s *{{ name|default(s.name) }}) ReadFields(reader meta.Reader) error { return err } } else { - {{ fname }} = v.(I{{ type.name }}) - {% if has_table_token %} - s.changedFields.SetChanged("{{ alias }}") - {% endif %} + if v != nil { + {{ fname }} = v.(I{{ type.name }}) + {% if has_table_token %} + s.changedFields.SetChanged("{{ alias }}") + {% endif %} + } } {% else %} if err := reader.BeginContainer("{{ alias }}"); err != nil {