summaryrefslogtreecommitdiff
path: root/generateFind.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-01-12 03:59:59 -0600
committerJeff Carr <[email protected]>2025-01-12 03:59:59 -0600
commitfb8e44d36c4e1b56fde089dffcaffdc3bb0384c5 (patch)
tree0e0e9dfdf5252af1a959959cdc213663d8e00b56 /generateFind.go
parentc956babe1b8fe57ad83d9294d79729bb1d104f76 (diff)
almost have Delete()
Diffstat (limited to 'generateFind.go')
-rw-r--r--generateFind.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/generateFind.go b/generateFind.go
index 1174efa..4ab9d10 100644
--- a/generateFind.go
+++ b/generateFind.go
@@ -38,10 +38,10 @@ func generateFindBy(w io.Writer, FRUIT, APPLES, APPLE, COLOR, LOCK string) {
fmt.Fprintln(w, "")
}
-func (msg *MsgName) deleteBy(w io.Writer, FRUIT, APPLES, APPLE, COLOR string) {
+func (msg *MsgName) deleteBy(w io.Writer, FRUIT, APPLES, APPLE, COLOR, FUNCNAME string) string {
LOCK := msg.getLockname("x")
- fmt.Fprintln(w, "func (x *"+FRUIT+") DeleteBy"+COLOR+"(s string) bool {")
+ fmt.Fprintln(w, "func (x *"+FRUIT+") "+FUNCNAME+"(s string) bool {")
fmt.Fprintln(w, " "+LOCK+".Lock()")
fmt.Fprintln(w, " defer "+LOCK+".Unlock()")
fmt.Fprintln(w, "")
@@ -55,14 +55,16 @@ func (msg *MsgName) deleteBy(w io.Writer, FRUIT, APPLES, APPLE, COLOR string) {
fmt.Fprintln(w, " return false")
fmt.Fprintln(w, "}")
fmt.Fprintln(w, "")
+
+ return "func (x *" + FRUIT + ") DeleteBy" + COLOR + "(s string) bool {"
}
// this tries to return the deleted one but is wrong/gives warning if mutex lock is in struct
-func (msg *MsgName) deleteByWithCopy(w io.Writer, FRUIT, APPLES, APPLE, COLOR string) {
+func (msg *MsgName) deleteByWithCopy(w io.Writer, FRUIT, APPLES, APPLE, COLOR, FUNCNAME string) string {
LOCK := msg.getLockname("x")
fmt.Fprintln(w, "// TESTING fails with 'go vet' warning")
- fmt.Fprintln(w, "func (x *"+FRUIT+") DeleteBy"+COLOR+"(s string) *"+APPLE+" {")
+ fmt.Fprintln(w, "func (x *"+FRUIT+") "+FUNCNAME+"(s string) *"+APPLE+" {")
fmt.Fprintln(w, " "+LOCK+".Lock()")
fmt.Fprintln(w, " defer "+LOCK+".Unlock()")
fmt.Fprintln(w, "")
@@ -79,6 +81,8 @@ func (msg *MsgName) deleteByWithCopy(w io.Writer, FRUIT, APPLES, APPLE, COLOR st
fmt.Fprintln(w, " return nil")
fmt.Fprintln(w, "}")
fmt.Fprintln(w, "")
+
+ return "func (x *" + FRUIT + ") DeleteBy" + COLOR + "(s string) *" + APPLE + " {"
}
// new 2025 idea. useful? TODO: look at this again in 1y