summaryrefslogtreecommitdiff
path: root/protoParse.go
diff options
context:
space:
mode:
Diffstat (limited to 'protoParse.go')
-rw-r--r--protoParse.go24
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)