Skip to content

Commit

Permalink
Fix crush with non-pointer nested structs
Browse files Browse the repository at this point in the history
  • Loading branch information
yuin committed May 19, 2024
1 parent 3a65062 commit 95bbc55
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -1032,7 +1032,8 @@ func genMapFuncBody(printer Printer,
for i := 1; i < len(parts); i++ {
nestName := strings.Join(parts[:i], ".")
nestField, ok := GetField(destStruct, nestName, mapping.IgnoreCase)
if ok {
_, pok := nestField.Type().(*types.Pointer)
if ok && pok {
p("if %s.%s == nil {", destNameBase, nestName)
p(" %s.%s = %s{}", destNameBase, nestName, strings.Replace(GetSource(nestField.Type(), mctx), "*", "&", 1))
p("}")
Expand Down

0 comments on commit 95bbc55

Please sign in to comment.