From 4e0b3b8f3873e1784b8ad43394c1ad8f8a9fb4fb Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 12 Jan 2025 09:40:18 -0600 Subject: [PATCH] cleanup output --- generate.go | 83 +++++++++++++++++------------------------------------ main.go | 5 ++-- 2 files changed, 28 insertions(+), 60 deletions(-) diff --git a/generate.go b/generate.go index 717393d..3e26aa8 100644 --- a/generate.go +++ b/generate.go @@ -22,20 +22,14 @@ func (pb *Files) makeNewSortfile(pf *File) error { fmt.Fprintf(wSort, "// START SORT\n") fmt.Fprintf(wSort, "\n") - log.Printf("START ITERATORS\n") // add iterators for all the structs to be used - for i, msg := range pf.allMsg() { - PARENT := msg.Name - LOCK := msg.Lockname - + for _, msg := range pf.allMsg() { funcdef := newIter(wSort, msg) - log.Printf("ITER: %-2d %20s %20s %20s %20s %s\n", i, PARENT, "", "", LOCK, funcdef) + log.Printf("%20s %s\n", "", funcdef) } - log.Printf("END ITERATORS\n") - log.Printf("\n") - log.Printf("START COMPARE\n") - for i, msg := range pf.allMsg() { + // log.Printf("START COMPARE\n") + for _, msg := range pf.allMsg() { PARENT := msg.Name for _, v := range msg.Vars { if !v.HasSort { @@ -47,14 +41,12 @@ func (pb *Files) makeNewSortfile(pf *File) error { } VARNAME := v.VarName funcdef := newSortType(wSort, PARENT, VARNAME) - log.Printf("TYPE: %-2d %20s %20s %20s %10s %s\n", i, PARENT, "", "", "", funcdef) + log.Printf("%20s %s\n", "", funcdef) } } - log.Printf("END COMPARE\n") - log.Printf("\n") // add selectAll() functions for all the sort combinations that will be used - for i, s := range pf.ToSort { + for _, s := range pf.ToSort { // log.Printf("SORT: %-2d %20s %20s %20s %20s\n", i, s.MsgName, s.VarType, s.VarName, s.Lockname) FRUIT := s.MsgName APPLE := s.VarType @@ -67,14 +59,12 @@ func (pb *Files) makeNewSortfile(pf *File) error { } funcdef := msg.newIterAll(wSort, FRUIT, APPLE, APPLES, LOCK) - log.Printf("JUNK: %-2d %20s %20s %20s %20s %s\n", i, FRUIT, APPLE, "", LOCK, funcdef) - log.Printf("JUNK: %-2d %20s %20s %20s %20s %s\n", i, FRUIT, APPLE, "", LOCK, funcdef) + log.Printf("%20s %s\n", "", funcdef) } - log.Printf("\n") - log.Printf("START SELECT\n") + // log.Printf("START SELECT\n") // make the sort iterators selectAll() - for i, s := range pf.ToSort { + for _, s := range pf.ToSort { PARENT := s.MsgName CHILD := s.VarType VARNAME := s.VarName @@ -86,33 +76,22 @@ func (pb *Files) makeNewSortfile(pf *File) error { } funcdef := msg.addSelectAll(wSort, PARENT, CHILD, VARNAME, LOCK) - log.Printf("SORT: %-2d %20s %20s %20s %20s %s\n", i, PARENT, CHILD, VARNAME, LOCK, funcdef) + log.Printf("%20s %s\n", "", funcdef) } - log.Printf("END SELECT\n") - log.Printf("\n") + // log.Printf("END SELECT\n") - log.Printf("START SORT\n") + // log.Printf("START SORT\n") // make the SortBy() functions - for i, s := range pf.ToSort { + for _, s := range pf.ToSort { // var funcname string PARENT := s.MsgName - CHILD := s.VarType VARNAME := s.VarName - log.Printf("SORT: %-2d %20s %20s %20s %20s %s\n", i, PARENT, CHILD, VARNAME, "", "") - msg := pf.findMsg(s.VarType) if msg == nil { return fmt.Errorf("failed to find struct %s", s.VarType) } - var FUNCTYPE string - if PARENT == VARNAME { - FUNCTYPE = PARENT - } else { - FUNCTYPE = VARNAME - } - for _, v := range msg.Vars { if v.IsRepeated { // can't work against slices @@ -134,16 +113,13 @@ func (pb *Files) makeNewSortfile(pf *File) error { sortname := s.VarType + v.VarName selectName := "selectAll" + VARNAME funcdef := newSortBy(wSort, PARENT, s.VarType, sortname, sortby, selectName, v.VarName) - log.Printf(" %-2s %20s %20s %20s %s %s\n", "", "", "", "", "", funcdef) + log.Printf("%20s %s\n", "", funcdef) } else { - funcname := "func (x *" + FUNCTYPE + ") SortBy" + v.VarName + "(" + v.VarType + ") *[]iter" + s.VarType + " # can not do this yet" - log.Printf(" %-2s %20s %20s %20s %s %s\n", "", "", "", "", "", funcname) + // funcdef := "func (x *" + FUNCTYPE + ") SortBy" + v.VarName + "(" + v.VarType + ") *[]iter" + s.VarType + " # can not do this yet" } } } } - log.Printf("END SORT\n") - log.Printf("\n") fmt.Fprintf(wSort, "\n") fmt.Fprintf(wSort, "// END SORT\n") @@ -153,9 +129,8 @@ func (pb *Files) makeNewSortfile(pf *File) error { PARENT := msg.Name LOCK := msg.Lockname - for i, v := range msg.Vars { + for _, v := range msg.Vars { if v.IsRepeated { - CHILD := v.VarType VARNAME := v.VarName // funcdef := "func (x *" + PARENT + ") Len" + VARNAME + "() int " + CHILD + " name:" + VARNAME @@ -163,7 +138,7 @@ func (pb *Files) makeNewSortfile(pf *File) error { // special case funcdef := addLenFunc(wSort, PARENT, VARNAME, LOCK) // + " " + v.VarType + " name:" + v.VarName funcdef += " # is special struct=varname" - log.Printf("LEN: %-2d %20s %20s %20s %20s %s\n", i, PARENT, CHILD, VARNAME, LOCK, funcdef) + log.Printf("%20s %s\n", "", funcdef) } if PARENT == VARNAME { // FUNCNAME := "Append" @@ -184,7 +159,7 @@ func (pb *Files) makeNewSortfile(pf *File) error { if PARENT == VARNAME { funcdef := addAllFunc(wSort, PARENT, CHILD, VARNAME) - log.Printf(" %-2s %20s %20s %20s %s %s\n", "", "", "", "done", "", funcdef) + log.Printf("%20s %s\n", "", funcdef) } /* @@ -206,15 +181,9 @@ func (pb *Files) makeNewSortfile(pf *File) error { } // add Find() Delete() Append() Insert() - log.Printf(" %-2s %20s %20s %20s %20s\n", "", "PARENT STRUCT", "VAR STRUCT TYPE", "VAR NAME", "LOCK") - for i, s := range pf.ToSort { - var funcname string + for _, s := range pf.ToSort { PARENT := s.MsgName - CHILD := s.VarType VARNAME := s.VarName - LOCK := s.Lockname - - log.Printf("SORT: %-2d %20s %20s %20s %20s %s\n", i, PARENT, CHILD, VARNAME, LOCK, "") msg := pf.findMsg(s.VarType) if msg == nil { @@ -239,7 +208,7 @@ func (pb *Files) makeNewSortfile(pf *File) error { funcdef := msg.generateFindBy(wSort, FUNCNAME, PARENT, VARNAME, s.VarType, v.VarName) // func (msg *MsgName) generateFindBy(w io.Writer, FUNCNAME, STRUCT, VARNAME, VARTYPE, COLOR string) string { - log.Printf(" %-2s %20s %20s %20s %s %s\n", "", "", "", "done", "", funcdef) + log.Printf("%20s %s\n", "", funcdef) } else { if v.VarType == "string" { // probably dumb. move to a database if you need this @@ -276,7 +245,7 @@ func (pb *Files) makeNewSortfile(pf *File) error { } else { funcdef = msg.deleteBy(wSort, FRUIT, APPLES, APPLE, COLOR, FUNCNAME, v.VarName) } - log.Printf(" %-2s %20s %20s %20s %s %s\n", "", "", "", "done", "", funcdef) + log.Printf("%20s %s\n", "", funcdef) } // AppendBy() functions. todo: fix these so Append() is for simple things and Insert() is for unique keys @@ -296,7 +265,7 @@ func (pb *Files) makeNewSortfile(pf *File) error { } else { FUNCNAME = "Append" + VARNAME + "By" + v.VarName funcdef := msg.addAppendBy(wSort, PARENT, FUNCNAME, VARNAME, v.VarName, s.VarType) - log.Printf(" %-2s %20s %20s %20s %s %s\n", "", "", "", "done", "", funcdef) + log.Printf("%20s %s\n", "", funcdef) } } @@ -306,13 +275,13 @@ func (pb *Files) makeNewSortfile(pf *File) error { if !v.HasUnique { continue } - funcname = "func (x *" + PARENT + ") Insert(a *" + v.VarType + ") (*" + CHILD + ", isNew bool) // todo" - log.Printf(" %-2s %20s %20s %20s %s %s\n", "", "", "", "", "", funcname) + //funcname = "func (x *" + PARENT + ") Insert(a *" + v.VarType + ") (*" + CHILD + ", isNew bool) // todo" + //log.Printf("%20s %s\n", "", funcdef) } } if ucount > 1 { - funcname = "func (x *" + PARENT + ") Insert(a *" + CHILD + ") (*" + CHILD + ", isNew bool) // todo" - log.Printf(" %-2s %20s %20s %20s %s %s\n", "", "", "", "", "", funcname) + //funcname = "func (x *" + PARENT + ") Insert(a *" + CHILD + ") (*" + CHILD + ", isNew bool) // todo" + //log.Printf("%20s %s\n", "", funcdef) } } return nil diff --git a/main.go b/main.go index 41c8f77..3f6f73b 100644 --- a/main.go +++ b/main.go @@ -88,11 +88,10 @@ func main() { } */ - // show the protobuf of the protobuf. It's like Inception - pf.printMsgTable() - // if you have gotten here, at least the .proto buf file is OK if argv.DryRun { + // show the protobuf of the protobuf. It's like Inception + pf.printMsgTable() okExit("") }