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