From 65fe2fa9c117b509898133aaeda841a4b153e625 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Thu, 28 Aug 2025 19:29:04 -0500 Subject: [PATCH] duh. always should proto.Clone on Append() --- generateAppend.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/generateAppend.go b/generateAppend.go index ac53974..df705f7 100644 --- a/generateAppend.go +++ b/generateAppend.go @@ -18,12 +18,12 @@ func (msg *MsgName) simpleAppend(w io.Writer, FRUIT, APPLES, APPLE string) strin // log.Printf("\t\t(x %s) APPEND(%s)\n", FRUIT, APPLE) // append -- no check at all - fmt.Fprintln(w, "// just a simple Append() shortcut (but still uses the mutex lock)") + fmt.Fprintln(w, "// a Append() shortcut (that does Clone() with a mutex) notsure if it really works") fmt.Fprintln(w, funcdef, "{") fmt.Fprintln(w, " "+LOCK+".Lock()") fmt.Fprintln(w, " defer "+LOCK+".Unlock()") fmt.Fprintln(w, "") - fmt.Fprintln(w, " x."+APPLES+" = append(x."+APPLES+", y)") + fmt.Fprintln(w, " x."+APPLES+" = append(x."+APPLES+", proto.Clone(y).(*"+APPLE+"))") fmt.Fprintln(w, "}") fmt.Fprintln(w, "") @@ -92,7 +92,7 @@ func (msg *MsgName) addAppendBy(w io.Writer, STRUCT, FUNCNAME, STRUCTVAR, VARNAM fmt.Fprintln(w, " }") fmt.Fprintln(w, " }") fmt.Fprintln(w, "") - fmt.Fprintln(w, " x."+STRUCTVAR+" = append(x."+STRUCTVAR+", y)") + fmt.Fprintln(w, " x."+STRUCTVAR+" = append(x."+STRUCTVAR+", proto.Clone(y).(*"+VARTYPE+"))") fmt.Fprintln(w, " return true") fmt.Fprintln(w, "}") fmt.Fprintln(w, "")