diff options
| author | Jeff Carr <[email protected]> | 2024-11-30 15:06:57 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-11-30 15:06:57 -0600 |
| commit | 3a4e0c1046276235488326bb4e032c801280fc15 (patch) | |
| tree | 339de3baf86334068825038f77b8139d9deb7af8 /sort.go | |
| parent | d2112f954d68fde00a4781c9f2d8ca8bec837055 (diff) | |
auto detect unique keys in protobuf filev0.0.5
Diffstat (limited to 'sort.go')
| -rw-r--r-- | sort.go | 19 |
1 files changed, 18 insertions, 1 deletions
@@ -5,6 +5,8 @@ import ( "io" "os" "strings" + + "go.wit.com/log" ) func makeSortfile() { @@ -22,6 +24,21 @@ func makeSortfile() { iterAppend(f, sortmap) // Append() enforce unique key argv.Append } + for _, s := range uniqueKeys { + log.Info("found unique key in .proto", s) + sortmap["sortBy"] = s + sortmap["sortKey"] = s + + iterSortBy(f, sortmap) + + sortmap["append"] = sortmap["sortKey"] + iterAppend(f, sortmap) // Append() enforce unique key argv.Append + + iterDelete(f, sortmap) + iterReplace(f, sortmap) + iterFind(f, sortmap) + } + for _, s := range argv.Sort { sortparts := strings.Split(s, ",") sortmap["sortBy"] = sortparts[0] @@ -133,7 +150,7 @@ func iterSortAll(w io.Writer, names map[string]string) { } func iterSortBy(w io.Writer, names map[string]string) { - fmt.Fprintln(w, "func (all *"+names["Bases"]+") Sort"+names["sortBy"]+"() *"+names["Base"]+"Iterator {") + fmt.Fprintln(w, "func (all *"+names["Bases"]+") SortBy"+names["sortBy"]+"() *"+names["Base"]+"Iterator {") fmt.Fprintln(w, " packs := all.selectAll"+names["Base"]+"()") fmt.Fprintln(w, "") fmt.Fprintln(w, " sort.Sort("+names["Base"]+""+names["sortBy"]+"(packs))") |
