duh. always should proto.Clone on Append()

This commit is contained in:
Jeff Carr 2025-08-28 19:29:04 -05:00
parent 931e7ac1a6
commit 65fe2fa9c1
1 changed files with 3 additions and 3 deletions

View File

@ -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, "")