Skip to content

Commit

Permalink
codegen: ensure Elem present before using (#1317)
Browse files Browse the repository at this point in the history
  • Loading branch information
tmc committed Oct 12, 2021
1 parent bfea93c commit 35199c4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions codegen/type.gotpl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
{{- if $type.Unmarshaler }}
{{- if $type.CastType }}
tmp, err := {{ $type.Unmarshaler | call }}(v)
{{- if $type.IsNilable }}
{{- if and $type.IsNilable $type.Elem }}
res := {{ $type.Elem.GO | ref }}(tmp)
{{- else}}
res := {{ $type.GO | ref }}(tmp)
Expand All @@ -48,7 +48,7 @@
{{- else if eq ($type.GO | ref) "map[string]interface{}" }}
return v.(map[string]interface{}), nil
{{- else if $type.IsMarshaler }}
{{- if $type.IsNilable }}
{{- if and $type.IsNilable $type.Elem }}
var res = new({{ $type.Elem.GO | ref }})
{{- else}}
var res {{ $type.GO | ref }}
Expand Down

0 comments on commit 35199c4

Please sign in to comment.