Name check for go-to-protobuf in wrong spot

This commit is contained in:
Clayton Coleman 2016-07-08 11:31:21 -04:00
parent becb3b44e7
commit 29046db6ff
No known key found for this signature in database
GPG Key ID: 3D16906B4F1C5CB3

View File

@ -125,9 +125,6 @@ func Run(g *Generator) {
protobufNames := NewProtobufNamer() protobufNames := NewProtobufNamer()
outputPackages := generator.Packages{} outputPackages := generator.Packages{}
for _, d := range strings.Split(g.Packages, ",") { for _, d := range strings.Split(g.Packages, ",") {
if strings.Contains(d, "-") {
log.Fatalf("Package names must be valid protobuf package identifiers, which allow only [a-z0-9_]: %s", d)
}
generateAllTypes, outputPackage := true, true generateAllTypes, outputPackage := true, true
switch { switch {
case strings.HasPrefix(d, "+"): case strings.HasPrefix(d, "+"):
@ -137,6 +134,9 @@ func Run(g *Generator) {
d = d[1:] d = d[1:]
outputPackage = false outputPackage = false
} }
if strings.Contains(d, "-") {
log.Fatalf("Package names must be valid protobuf package identifiers, which allow only [a-z0-9_]: %s", d)
}
name := protoSafePackage(d) name := protoSafePackage(d)
parts := strings.SplitN(d, "=", 2) parts := strings.SplitN(d, "=", 2)
if len(parts) > 1 { if len(parts) > 1 {