I get : ../.../...pb.go:21:11: undefined: proto.ProtoPackageIsVersion3
我想要版本 2
我安装了protoc
from https://github.com/google/protobuf/releases $ protoc --version
gives libprotoc 3.6.0
。我也安装了golang-goprotobuf-dev
from apt
.
问题:
- protoc(protobuffer编译器总是编译到Proto3版本?)
- 需要什么额外的 go 支持?
- 如何获得可以编译为 Proto2 的编译器?
- 我注意到在一个系统中 libproto 3.6.1 编译为 proto2,我不明白这一点。
-
protoc(protobuffer编译器总是编译到Proto3版本?)
这取决于你的 protobuf 版本和 protoc-gen-go 版本。
-
需要什么额外的 go 支持?
我想你需要安装原型-gen-go https://github.com/golang/protobuf
-
如何获得可以编译为 Proto2 的编译器?
安装特定版本的 protoc-gen-go
GIT_TAG="v1.2.0" # change as needed
go get -d -u github.com/golang/protobuf/protoc-gen-go
git -C "$(go env GOPATH)"/src/github.com/golang/protobuf checkout $GIT_TAG
go install github.com/golang/protobuf/protoc-gen-go
-
我注意到在一个系统中 libproto 3.6.1 编译为 proto2,我不明白这一点。
对此不太确定,但如果我没记错的话,决定因素是你的 protoc-gen-go 版本。
希望能帮助到你!
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)