return new pointer from Append()

This commit is contained in:
Jeff Carr 2025-09-13 05:31:59 -05:00
parent 8a53184746
commit ddea4b6514
1 changed files with 5 additions and 2 deletions

View File

@ -14,7 +14,7 @@ import (
func (msg *MsgName) simpleAppend(w io.Writer, FRUIT, APPLES, APPLE string) string {
LOCK := msg.getLockname("x")
funcdef := "func (x *" + FRUIT + ") Append(y *" + APPLE + ")"
funcdef := "func (x *" + FRUIT + ") Append(y *" + APPLE + ") *" + APPLE
// log.Printf("\t\t(x %s) APPEND(%s)\n", FRUIT, APPLE)
// append -- no check at all
@ -23,7 +23,10 @@ func (msg *MsgName) simpleAppend(w io.Writer, FRUIT, APPLES, APPLE string) strin
fmt.Fprintln(w, " "+LOCK+".Lock()")
fmt.Fprintln(w, " defer "+LOCK+".Unlock()")
fmt.Fprintln(w, "")
fmt.Fprintln(w, " x."+APPLES+" = append(x."+APPLES+", proto.Clone(y).(*"+APPLE+"))")
fmt.Fprintln(w, " z := proto.Clone(y).(*"+APPLE+")")
fmt.Fprintln(w, " x."+APPLES+" = append(x."+APPLES+", z)")
fmt.Fprintln(w, "")
fmt.Fprintln(w, " return z")
fmt.Fprintln(w, "}")
fmt.Fprintln(w, "")