diff options
| author | Jeff Carr <[email protected]> | 2025-01-09 04:22:11 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-01-09 04:22:11 -0600 |
| commit | 213f719621e8fe107201b9393eda420ad7f54965 (patch) | |
| tree | d4d2cf3f93c7818dbc342b77aea40dddb3b938aa /protoParse.go | |
| parent | d67c2eb3a283138b5c08318b232311ecd8971f97 (diff) | |
first pass parsing done
Diffstat (limited to 'protoParse.go')
| -rw-r--r-- | protoParse.go | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/protoParse.go b/protoParse.go index a27a4fb..c9feb47 100644 --- a/protoParse.go +++ b/protoParse.go @@ -16,7 +16,7 @@ import ( // finds autogenpb:marshal and autogenpb:unique in the .proto file // // adds fields to []marshal and []unique -func (pb *Files) findAutogenpb(f *File) error { +func (pb *Files) protoParseNew(f *File) error { // log.Info("starting findAutogenpb() on", names["protofile"]) // read in the .proto file data, err := os.ReadFile(f.Filename) @@ -41,22 +41,29 @@ func (pb *Files) findAutogenpb(f *File) error { if strings.Contains(line, "autogenpb:sort") { if parts[0] == "repeated" { - newm := parts[1] + newS := parts[1] if curmsg == nil { - log.Info("Error: Found Sort for:", newm, "however, this struct can't be used") + log.Info("Error: Found Sort for:", newS, "however, this struct can't be used") } else { - log.Info("Found Sort for:", newm, "in struct", curmsg.Name) + log.Info("Addded Sort:", newS, "in struct", curmsg.Name) + curmsg.Sort = append(curmsg.Sort, newS) } } else { log.Info("Error:", line) log.Info("Error: can not sort on non repeated fields") } } + if strings.Contains(line, "autogenpb:unique") { if parts[0] == "repeated" { - newu := parts[1] - newu = cases.Title(language.English, cases.NoLower).String(newu) - log.Info("Found unique field", newu, "in struct", curmsg.Name) + newU := parts[1] + newU = cases.Title(language.English, cases.NoLower).String(newU) + if curmsg == nil { + log.Info("Error: Found Unique for:", newU, "however, this struct can't be used") + } else { + log.Info("Added Unique:", newU, "in struct", curmsg.Name) + curmsg.Unique = append(curmsg.Unique, newU) + } } else { log.Info("Error:", line) log.Info("Error: can not append on non repeated fields") @@ -88,7 +95,8 @@ func (f *File) parseForMessage(line string) *MsgName { return msg } -func (pb *Files) findGlobalAutogenpb(f *File) error { +// this doesn't do anything anymore (?) +func (pb *Files) protoParse(f *File) error { // log.Info("starting findAutogenpb() on", filename) // read in the .proto file data, err := os.ReadFile(f.Filename) |
