duh. always should proto.Clone on Append()
This commit is contained in:
parent
931e7ac1a6
commit
65fe2fa9c1
|
@ -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, "")
|
||||
|
|
Loading…
Reference in New Issue