From 6ad10141cda8eb1f9720c477eb37a2e72facf954 Mon Sep 17 00:00:00 2001 From: Akshay Patil Date: Tue, 31 Aug 2021 05:20:26 +0000 Subject: [PATCH] Fixed GetMessage Helper Method --- protoc-gen-gogo/descriptor/helper.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/protoc-gen-gogo/descriptor/helper.go b/protoc-gen-gogo/descriptor/helper.go index e0846a357d..2d7aee8a1a 100644 --- a/protoc-gen-gogo/descriptor/helper.go +++ b/protoc-gen-gogo/descriptor/helper.go @@ -152,9 +152,12 @@ func (file *FileDescriptorProto) GetMessage(typeName string) *DescriptorProto { if msg.GetName() == typeName { return msg } - nes := file.GetNestedMessage(msg, strings.TrimPrefix(typeName, msg.GetName()+".")) - if nes != nil { - return nes + prefix := msg.GetName() + "." + if strings.HasPrefix(typeName, prefix) { + nes := file.GetNestedMessage(msg, strings.TrimPrefix(typeName, prefix)) + if nes != nil { + return nes + } } } return nil