Hello,
I have a microservice that uses grpc 1.0 with protobuf 3.0.0 that works just fine in darwin/amd64. If the same steps are carried out to generate *.pb.go files in an alpine container, it results in a compile time assertion.
In the generated code, the difference is as follows:
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
-const _ = grpc.SupportPackageIsVersion3
+const _ = grpc.SupportPackageIsVersion4
The same build steps are done in darwin as in the alpine build container, which is as follows:
git clone https://github.com/google/protobuf && \
cd protobuf && \
./autogen.sh && \
./configure && \
make && \
make check && \
make install && \
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway && \
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger && \
go get -u github.com/golang/protobuf/proto && \
go get -u github.com/golang/protobuf/protoc-gen-go
I'm new to GRPC/HTTP/2, so I could be missing something obvious - If not, has anyone run into this issue?
Thanks,
Ajith
Same problem here. grpc.SupportPackageIsVersion4 breaks public API. It looks like it should be version v4.0.0 but was released as v1.0.4. Otherwise entire versioning is completely useless here.
This check is to make sure the proto package, the gRPC package and the generated code are in sync.
This should be fixed by
go get -u github.com/golang/protobuf/{proto,protoc-gen-go}.go get -u google.golang.org/grpcprotoc --go_out=plugins=grpc:. *.proto.grpc.SupportPackageIsVersion is used to track the version of the protobuf generated code and is different from the grpc release version. Menghanl made an faq (https://github.com/grpc/grpc-go/pull/970/files) to address this type of questions.
@iamqizhao : go get -u on both grpc and protobuf/{proto, protoc-gen-go} doesn't solve this.
rebuild your proto files with protoc --go_out=plugins=grpc:. *.proto
What about this?
Yes, the proto files were regenerated. Same failure in building the project after the *.pb.go and *.gw.go files are generated.
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion4
service.pb.go:333: undefined: grpc.SupportPackageIsVersion4
This error indicates your gRPC package is not updated.
If you already did go get -u google.golang.org/grpc, you should be able to find this variable in your local grpc package: https://github.com/grpc/grpc-go/blob/master/rpc_util.go#L457.
And if you use go vendor, make sure the vendored grpc is updated.
Thanks, this was useful!
Thanks, updating the grpc packages worked for me.
Most helpful comment
This check is to make sure the proto package, the gRPC package and the generated code are in sync.
This should be fixed by
go get -u github.com/golang/protobuf/{proto,protoc-gen-go}.go get -u google.golang.org/grpcprotoc --go_out=plugins=grpc:. *.proto.