diff --git a/generateAppend.go b/generateAppend.go index df705f7..c81dcfb 100644 --- a/generateAppend.go +++ b/generateAppend.go @@ -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, "")