summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go29
1 files changed, 19 insertions, 10 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()")