From 6106c552da4d41005852fb6791e4532f1fa32f2f Mon Sep 17 00:00:00 2001 From: Valerio Gheri Date: Tue, 27 Dec 2016 17:56:44 +0100 Subject: [PATCH] Fixed getMessageType to use equality comparison to avoid side effects --- helpers.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/helpers.go b/helpers.go index b8479ae..6ec72e8 100644 --- a/helpers.go +++ b/helpers.go @@ -71,9 +71,12 @@ func init() { } func getMessageType(f *descriptor.FileDescriptorProto, name string) *descriptor.DescriptorProto { + // name is in the form .packageName.MessageTypeName.InnerMessageTypeName... + // e.g. .article.ProductTag + splits := strings.Split(name, ".") + target := splits[len(splits)-1] for _, m := range f.MessageType { - // name usually contains the package name - if strings.HasSuffix(name, *m.Name) { + if target == *m.Name { return m } }