From d850ec82c849d9226a9558e46ad4ad226c91a16e Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Wed, 8 Jan 2025 20:30:33 -0600 Subject: [PATCH] found mutex --- main.go | 4 ++-- parseProtoFile.go | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 5ed9080..451ffd5 100644 --- a/main.go +++ b/main.go @@ -133,7 +133,7 @@ func main() { // parse sort & marshal options from the .proto file // this goes through the .proto files and looks // for `autogenpb: ` lines - if err := findAutogenpb(sortmap); err != nil { + if err := pb.findAutogenpb(f); err != nil { log.Info("autogenpb parse error:", err) os.Exit(-1) } @@ -148,7 +148,7 @@ func main() { os.Exit(-1) } pb.addMutex(f) - os.Exit(0) + // os.Exit(0) /* // experiment to add a mutex to the structs. diff --git a/parseProtoFile.go b/parseProtoFile.go index c1aa390..cbe670a 100644 --- a/parseProtoFile.go +++ b/parseProtoFile.go @@ -11,13 +11,15 @@ import ( "golang.org/x/text/language" ) +// this parses the .proto file and handles anything with `autogenpb: ` + // finds autogenpb:marshal and autogenpb:unique in the .proto file // // adds fields to []marshal and []unique -func findAutogenpb(names map[string]string) error { +func (pb *Files) findAutogenpb(f *File) error { // log.Info("starting findAutogenpb() on", names["protofile"]) // read in the .proto file - data, err := os.ReadFile(names["protofile"]) + data, err := os.ReadFile(f.Filename) if err != nil { // log.Info("open config file :", err) return err @@ -39,6 +41,14 @@ func findAutogenpb(names map[string]string) error { // log.Info("found unique field", newu) uniqueKeys = append(uniqueKeys, newu) } + if strings.Contains(line, "autogenpb:mutex") { + parts := strings.Split(line, "autogenpb:mutex") + // log.Info("FOUND MUTEX line:", parts[0]) + fields := strings.Fields(parts[0]) + if fields[0] == "message" { + log.Info("FOUND MUTEX:", fields[1]) + } + } } return nil }