golang 根据protobuf消息名称获取实例对象
今天在使用golang的protoful作为通信消息协议的时候,发现我们必须手动写死消息名称来对应处理消息的func,极为不便,不符合策略模式的设计模式,经过一天的查找最终找到以下解决方法获取proto Message的全类名// GetFullNameByMessage 获取pb协议的全类名func GetFullNameByMessage(msg proto.Message) string { reflect := proto.MessageReflect(msg) descripto
原创
2021-06-01 10:28:38 ·
2568 阅读 ·
0 评论