Default value for virtual with default null

This commit is contained in:
Sergey Polygalin 2023-11-23 13:46:51 +03:00
parent 9eb9d71175
commit 17d8186616
1 changed files with 11 additions and 3 deletions

View File

@ -479,10 +479,18 @@ func (s *{{ name|default(o.name) }}) Reset() {
s.{{ fname }} = s.{{ fname }}[:0]
}
{% elseif f.type is struct %}
{% if has_token(f, 'virtual') %}
s.{{ fname }} = New{{ f.type|go_type }}()
{% if token(f, 'default', '') != 'null' %}
{% if has_token(f, 'virtual') %}
s.{{ fname }} = New{{ f.type|go_type }}()
{% else %}
s.{{ fname }}.Reset()
{% endif %}
{% else %}
s.{{ fname }}.Reset()
{% if has_token(f, 'virtual') %}
s.{{ fname }} = &{{ f.type|go_type }}{}
{% else %}
s.{{ fname }}.Reset()
{% endif %}
{% endif %}
{% else %}
s.{{ fname }} = {{ f|default_val }}