better function names
This commit is contained in:
parent
93b5b4a9ca
commit
2329bc364e
14
protoc.go
14
protoc.go
|
@ -54,9 +54,13 @@ func ValidProtobuf(filename string) (string, string, error) {
|
|||
scanner.Scan()
|
||||
line = scanner.Text()
|
||||
fields := strings.Fields(line)
|
||||
if len(fields) < 2 {
|
||||
noUuidExit(filename)
|
||||
return "", "", fmt.Errorf("proto file does not have a UUID")
|
||||
}
|
||||
// log.Info("GOT LINE", line)
|
||||
if fields[0] == "string" && fields[1] != "uuid" {
|
||||
noUuid(filename)
|
||||
noUuidExit(filename)
|
||||
return "", "", fmt.Errorf("proto file does not have a UUID")
|
||||
}
|
||||
// ok, uuid is here
|
||||
|
@ -68,7 +72,7 @@ func ValidProtobuf(filename string) (string, string, error) {
|
|||
fields = strings.Fields(line)
|
||||
// log.Info("GOT LINE", line)
|
||||
if fields[0] == "string" && fields[1] != "version" {
|
||||
noUuid(filename)
|
||||
noUuidExit(filename)
|
||||
return "", "", fmt.Errorf("proto file does not have a version")
|
||||
}
|
||||
// found "version", the .proto file conforms
|
||||
|
@ -77,11 +81,11 @@ func ValidProtobuf(filename string) (string, string, error) {
|
|||
return UUID, version, nil
|
||||
}
|
||||
// right now, noPluralMessage does os.Exit(-1)
|
||||
// return "", "", noPluralMessage(filename)
|
||||
noPluralMessageExit(filename)
|
||||
return "", "", fmt.Errorf("proto file does not have message %s", pluralBase)
|
||||
}
|
||||
|
||||
func noPluralMessage(filename string) {
|
||||
func noPluralMessageExit(filename string) {
|
||||
filebase := strings.TrimSuffix(filename, ".proto")
|
||||
base := cases.Title(language.English, cases.NoLower).String(filebase)
|
||||
|
||||
|
@ -106,7 +110,7 @@ func noPluralMessage(filename string) {
|
|||
// repeated Fruit Fruits = 3; // THIS MUST BE "Fruit" and then "Fruit" + "s"
|
||||
// }
|
||||
|
||||
func noUuid(filename string) {
|
||||
func noUuidExit(filename string) {
|
||||
filebase := strings.TrimSuffix(filename, ".proto")
|
||||
base := cases.Title(language.English, cases.NoLower).String(filebase)
|
||||
id := uuid.New()
|
||||
|
|
Loading…
Reference in New Issue