Merge pull request #54 from moul/dev/proullon/gotype

fix (gotype helper): when leading pkg is empty string, remove leading dot
This commit is contained in:
Manfred Touron 2017-04-06 15:11:35 +02:00 committed by GitHub
commit a4fbdd0369

View File

@ -147,10 +147,13 @@ func goType(pkg string, f *descriptor.FieldDescriptorProto) string {
} }
return "string" return "string"
case descriptor.FieldDescriptorProto_TYPE_MESSAGE: case descriptor.FieldDescriptorProto_TYPE_MESSAGE:
if *f.Label == descriptor.FieldDescriptorProto_LABEL_REPEATED { if pkg != "" {
return fmt.Sprintf("[]*%s.%s", pkg, shortType(*f.TypeName)) pkg = pkg + "."
} }
return fmt.Sprintf("*%s.%s", pkg, shortType(*f.TypeName)) if *f.Label == descriptor.FieldDescriptorProto_LABEL_REPEATED {
return fmt.Sprintf("[]*%s%s", pkg, shortType(*f.TypeName))
}
return fmt.Sprintf("*%s%s", pkg, shortType(*f.TypeName))
case descriptor.FieldDescriptorProto_TYPE_BYTES: case descriptor.FieldDescriptorProto_TYPE_BYTES:
if *f.Label == descriptor.FieldDescriptorProto_LABEL_REPEATED { if *f.Label == descriptor.FieldDescriptorProto_LABEL_REPEATED {
return "[]byte" return "[]byte"