summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-11-29 14:18:35 -0600
committerJeff Carr <[email protected]>2024-11-29 14:18:35 -0600
commit678cb67c9be01a4a785ff24065d5b68e869a770e (patch)
tree8740e50a4b925e64e8dba877290760d9a21074b1
parent98b366e2df3da8771a4840136d4b671658025c47 (diff)
fix Append() logic
Signed-off-by: Jeff Carr <[email protected]>
-rw-r--r--main.go29
-rw-r--r--testautogen/Makefile4
2 files changed, 21 insertions, 12 deletions
diff --git a/main.go b/main.go
index 3be3730..a2f8e6b 100644
--- a/main.go
+++ b/main.go
@@ -86,18 +86,17 @@ func main() {
iterTop(f, sortmap)
iterNext(f, sortmap)
- // setup Append() functions
- if argv.Append == "" {
- iterAppend(f, sortmap) // Append() enforce no unique keys
- } else {
- iterAppend(f, sortmap) // Append() enforce no unique keys
- sortmap["append"] = argv.Append
- iterAppend(f, sortmap) // Append() enforce unique key argv.Append
- }
-
// setup Sort() functions
if len(argv.Sort) == 0 {
// don't do any sorting
+ // setup Append() functions
+ if argv.Append == "" {
+ iterAppend(f, sortmap) // Append() enforce no unique keys
+ } else {
+ iterAppend(f, sortmap) // Append() enforce no unique keys
+ sortmap["append"] = argv.Append
+ iterAppend(f, sortmap) // Append() enforce unique key argv.Append
+ }
} else {
sortparts := strings.Split(argv.Sort[0], ",")
sortmap["sortBy"] = sortparts[0]
@@ -105,6 +104,16 @@ func main() {
iterSort(f, sortmap)
+ if argv.Append == "" {
+ iterAppend(f, sortmap) // Append() enforce no unique keys
+ } else {
+ iterAppend(f, sortmap) // Append() enforce no unique keys
+ sortmap["append"] = argv.Append
+ iterAppend(f, sortmap) // Append() enforce unique key argv.Append
+ }
+ sortmap["append"] = sortmap["sortKey"]
+ iterAppend(f, sortmap) // Append() enforce unique key argv.Append
+
// add ReplaceKey()
iterDelete(f, sortmap)
iterReplace(f, sortmap)
@@ -255,7 +264,7 @@ func iterAppend(w io.Writer, names map[string]string) {
fmt.Fprintln(w, "func (all *"+names["Bases"]+") Append(newP *"+names["Base"]+") bool {")
} else {
// fmt.Fprintln(w, "func (all *"+names["Bases"]+") Append(newP *"+names["Base"]+") bool { // todo: make unique name here")
- fmt.Fprintln(w, "func (all *"+names["Bases"]+") AppendUnique(newP *"+names["Base"]+") bool {")
+ fmt.Fprintln(w, "func (all *"+names["Bases"]+") AppendUnique"+names["append"]+"(newP *"+names["Base"]+") bool {")
}
fmt.Fprintln(w, " "+names["lock"]+".Lock()")
fmt.Fprintln(w, " defer "+names["lock"]+".Unlock()")
diff --git a/testautogen/Makefile b/testautogen/Makefile
index a1bf723..476e3d0 100644
--- a/testautogen/Makefile
+++ b/testautogen/Makefile
@@ -6,8 +6,8 @@ test: vet
all: clean test.pb.go forgeConfig.pb.go run
run:
- ../autogenpb --proto test.proto --lobase gitTag --upbase GitTag --sort "ByPath,Refname" --marshal GitTags --append Refname
- ../autogenpb --proto forgeConfig.proto --sort "ByPath,GoPath" --append GoPath
+ ../autogenpb --proto test.proto --lobase gitTag --upbase GitTag --sort "ByPath,Refname" --marshal GitTags --append Subject
+ ../autogenpb --proto forgeConfig.proto --sort "ByPath,GoPath" # --append GoPath
vet:
@GO111MODULE=off go vet