Compiler assertion failed due to possible mismatch in protobuf version

30 views
Skip to first unread message

Niket Agrawal

unread,
Aug 5, 2019, 7:15:41 PM8/5/19
to Protocol Buffers
Hello,

I'm using protobuf with GROC in Golang. I followed the instructions on the GRPC quick start for Go here https://grpc.io/docs/quickstart/go/. Following are the steps I took to install the needed software and tools.
1. Installed the protoc compiler using the pre-compiled binaries available here - https://github.com/protocolbuffers/protobuf/releases . Chose protobuf-3.9.0-linux-arch_64.zip package as per the instructions on the link above.
2. Installed the protoc plugin for Go using the command go get -u github.com/golang/protobuf/protoc-gen-go

protoc version is libprotoc 3.9.0 as checked after completing the above steps.

I proceeded with creating a simple .proto file with the following content.

---------------------------------------------------------------------
syntax = "proto3";

package api;

service HiService{
    rpc SayHi (HiRequest) returns (HiResponse);
}

message HiRequest{
    string hi = 1;
}

message HiResponse{
    string hireply = 1;
}

-------------------------------------------------------------------- 

To generate the corresponding .pb.go file I used the command -> protoc --go_out=. file.proto. The .pb.go file has a compile time assertion in it (pasted below) that checks for proto package version and says that if the compilation fails at this particular line, proto package needs to be updated.

// This is a compile-time assertion to ensure that this generated file

// is compatible with the proto package it is being compiled against.

// A compilation error at this line likely means your copy of the

// proto package needs to be updated.

const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package



The .proto and .pb.go files were compiled together with another project and the compilation failed pointing out exactly the very same compile time assertion line in the code. 

I do not understand how there is a mismatch in the package versions in the first place? and how do I make them consistent?


Regards,
Niket 

Niket Agrawal

unread,
Aug 6, 2019, 1:09:41 PM8/6/19
to Protocol Buffers
This issue is resolved after consulting https://github.com/golang/protobuf/issues/763
Reply all
Reply to author
Forward
0 new messages