From 263cb87b9ce663ad5c7c9fb74aa627d7e7c40f01 Mon Sep 17 00:00:00 2001 From: Pierre Roullon Date: Thu, 6 Apr 2017 14:40:41 +0200 Subject: [PATCH] fix (gotype helper): when leading pkg is empty string, remove leading dot --- helpers.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/helpers.go b/helpers.go index 48dee17..d1e45c8 100644 --- a/helpers.go +++ b/helpers.go @@ -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"