diff options
Diffstat (limited to 'parseProtoFile.go')
| -rw-r--r-- | parseProtoFile.go | 43 |
1 files changed, 40 insertions, 3 deletions
diff --git a/parseProtoFile.go b/parseProtoFile.go index 682234d..afc1e05 100644 --- a/parseProtoFile.go +++ b/parseProtoFile.go @@ -15,7 +15,7 @@ import ( // // adds fields to []marshal and []unique func findAutogenpb(names map[string]string) error { - log.Info("starting findAutogenpb() on", names["protofile"]) + // log.Info("starting findAutogenpb() on", names["protofile"]) // read in the .proto file data, err := os.ReadFile(names["protofile"]) if err != nil { @@ -30,15 +30,52 @@ func findAutogenpb(names map[string]string) error { parts := strings.Fields(line) if strings.Contains(line, "autogenpb:marshal") { newm := parts[1] - log.Info("found marshal", newm) + // log.Info("found marshal", newm) marshalKeys = append(marshalKeys, newm) } if strings.Contains(line, "autogenpb:unique") { newu := parts[1] newu = cases.Title(language.English, cases.NoLower).String(newu) - log.Info("found unique field", newu) + // log.Info("found unique field", newu) uniqueKeys = append(uniqueKeys, newu) } } return nil } + +func findGlobalAutogenpb(filename string) error { + // log.Info("starting findAutogenpb() on", filename) + // read in the .proto file + data, err := os.ReadFile(filename) + if err != nil { + // log.Info("open config file :", err) + return err + } + + lines := strings.Split(string(data), "\n") + for _, line := range lines { + if strings.Contains(line, "autogenpb:ignoreproto") { + // ignore this protofile completely (don't make foo.pb.go) + os.Exit(0) + } + if strings.Contains(line, "autogenpb:no-marshal") { + // don't marshal anything (don't make foo.marshal.pb.go) + argv.NoMarshal = true + } + if strings.Contains(line, "autogenpb:no-sort") { + // don't sort anything (don't make foo.sort.pb.go) + argv.NoSort = true + } + if strings.Contains(line, "autogenpb:mutex") { + // try the mutex hack + argv.Mutex = true + } + if strings.Contains(line, "autogenpb:gover:") { + // todo: parse the output here + parts := strings.Split(line, "autogenpb:gover:") + log.Info("found gover:", parts[1]) + argv.Mutex = true + } + } + return nil +} |
