allow english plurals with "es" suffix
This commit is contained in:
parent
25f2b0fc35
commit
95d8d105e7
12
protoc.go
12
protoc.go
|
@ -33,7 +33,8 @@ This returns (UUID, Version, error on failure)
|
||||||
func ValidProtobuf(filename string) (string, string, error) {
|
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 {
|
||||||
|
@ -46,9 +47,12 @@ func ValidProtobuf(filename string) (string, string, error) {
|
||||||
|
|
||||||
prefix := "message " + pluralBase + " {"
|
prefix := "message " + pluralBase + " {"
|
||||||
if !strings.HasPrefix(line, prefix) {
|
if !strings.HasPrefix(line, prefix) {
|
||||||
// log.Info("nope", prefix, "line", line)
|
prefix = "message " + pluralBase2 + " {"
|
||||||
// nope, not this line
|
if !strings.HasPrefix(line, prefix) {
|
||||||
continue
|
// log.Info("nope", prefix, "line", line)
|
||||||
|
// nope, not this line
|
||||||
|
continue
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
scanner.Scan()
|
scanner.Scan()
|
||||||
|
|
Loading…
Reference in New Issue