I get : ../.../...pb.go:21:11: undefined: proto.ProtoPackageIsVersion3
I want it to Version 2
I installed protoc
from https://github.com/google/protobuf/releases $ protoc --version
gives libprotoc 3.6.0
. I also installed golang-goprotobuf-dev
from apt
.
Questions:
protoc (protobuffer compiler compiles always to version Proto3?)
It depends on your protobuf version and your protoc-gen-go version.
What is the additional go support required?
I think you'll need to install protoc-gen-go
How can I get a compiler that compiles to Proto2?
Install specific version of 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
I noticed in one system libproto 3.6.1 compiles to proto2, I don't understand this.
Not sure about this one, but if I remember correctly, the determining factor is your protoc-gen-go version.
Hope it helps!
if you have encountered the following error:
undefined: proto.ProtoPackageIsVersion3
its because the protoc-gen-go's version not correct.
$ git clone https://github.com/golang/protobuf
$ cd ~/protobuf/protoc-gen-go
$ git checkout tags/v1.2.0 -b v1.2.0
$ go install
Hope it help!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With