From aebe6bc644b2230ce0aee99288560270f145e664 Mon Sep 17 00:00:00 2001 From: Pavel Merzlyakov Date: Thu, 23 Nov 2023 17:36:02 +0300 Subject: [PATCH] fix interface convertion for null virtual field --- tpl/macros_struct.twig | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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 {