Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

undefined: proto.ProtoPackageIsVersion3

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:

  1. protoc (protobuffer compiler compiles always to version Proto3?)
  2. What is the additional go support required?
  3. How can I get a compiler that compiles to Proto2?
  4. I noticed in one system libproto 3.6.1 compiles to proto2, I don't understand this.
like image 276
Abhishek Bhatia Avatar asked Dec 28 '18 01:12

Abhishek Bhatia


2 Answers

  1. protoc (protobuffer compiler compiles always to version Proto3?)

    It depends on your protobuf version and your protoc-gen-go version.

  2. What is the additional go support required?

    I think you'll need to install protoc-gen-go

  3. 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
    
  4. 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!

like image 145
Andy Aldo Avatar answered Nov 14 '22 17:11

Andy Aldo


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!

like image 2
xiaolong ran Avatar answered Nov 14 '22 16:11

xiaolong ran