admin管理员组

文章数量:1636810

在学习protobuf做第一个小例子时出现如下错误:

# command-line-arguments
./test_proto.go:23:29: cannot use test (type *Student) as type protoreflect.ProtoMessage in argument to marshaler.Marshal:
        *Student does not implement protoreflect.ProtoMessage (missing ProtoReflect method)
./test_proto.go:29:21: cannot use newTest (type *Student) as type protoreflect.ProtoMessage in argument to "google.golang/protobuf/proto".Unmarshal:
        *Student does not implement protoreflect.ProtoMessage (missing ProtoReflect method)

解决方法:

一开始将这边使用成

"google.golang/protobuf/proto"

后改称上述形式就可以了,要使用go mod tidy在进行编译就可

本文标签: protoreflectimplementprotocProtoMessagemethod