allow english plurals with "es" suffix

This commit is contained in:
Jeff Carr 2025-09-23 07:43:40 -05:00
parent 25f2b0fc35
commit 95d8d105e7
1 changed files with 8 additions and 4 deletions

View File

@ -34,6 +34,7 @@ func ValidProtobuf(filename string) (string, string, error) {
filebase := strings.TrimSuffix(filename, ".proto") filebase := strings.TrimSuffix(filename, ".proto")
base := cases.Title(language.English, cases.NoLower).String(filebase) base := cases.Title(language.English, cases.NoLower).String(filebase)
pluralBase := base + "s" // to conform to autogenpb, it must have an added 's' pluralBase := base + "s" // to conform to autogenpb, it must have an added 's'
pluralBase2 := base + "es" // english is annoying, so allow this too
file, err := os.Open(filename) file, err := os.Open(filename)
if err != nil { if err != nil {
@ -45,11 +46,14 @@ func ValidProtobuf(filename string) (string, string, error) {
line := scanner.Text() line := scanner.Text()
prefix := "message " + pluralBase + " {" prefix := "message " + pluralBase + " {"
if !strings.HasPrefix(line, prefix) {
prefix = "message " + pluralBase2 + " {"
if !strings.HasPrefix(line, prefix) { if !strings.HasPrefix(line, prefix) {
// log.Info("nope", prefix, "line", line) // log.Info("nope", prefix, "line", line)
// nope, not this line // nope, not this line
continue continue
} }
}
scanner.Scan() scanner.Scan()
line = scanner.Text() line = scanner.Text()