fix (gotype helper): when leading pkg is empty string, remove leading dot

This commit is contained in:
Pierre Roullon 2017-04-06 14:40:41 +02:00
parent 7393098e01
commit 263cb87b9c

View File

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