found mutex

This commit is contained in:
Jeff Carr 2025-01-08 20:30:33 -06:00
parent 40bb6caf20
commit d850ec82c8
2 changed files with 14 additions and 4 deletions

View File

@ -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.

View File

@ -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
}