Fixed getMessageType to use equality comparison to avoid side effects
This commit is contained in:
parent
cdb9580565
commit
6106c552da
@ -71,9 +71,12 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getMessageType(f *descriptor.FileDescriptorProto, name string) *descriptor.DescriptorProto {
|
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 {
|
for _, m := range f.MessageType {
|
||||||
// name usually contains the package name
|
if target == *m.Name {
|
||||||
if strings.HasSuffix(name, *m.Name) {
|
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user