Reputation: 3877
I'm new to gRPC, trying to generate go code from protos and getting this error on the generated file
Generated code with issue:
// protoc-gen-go v1.25.0
// protoc v3.12.3
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
Error
Const initializer 'protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)' is not a constant
Versions:
$ sw_vers (sadc1c/opsvisibility)
ProductName: Mac OS X
ProductVersion: 10.15.3
BuildVersion: 19D76
$ go version
go version go1.14 darwin/amd64
$ protoc --version (sadc1c/opsvisibility)
libprotoc 3.12.3
Upvotes: 1
Views: 1629
Reputation: 3877
The cause was a bad version of the package google.golang.org/protobuf
The solution is to get the latest version
go get -u google.golang.org/protobuf/proto
Source: https://developers.google.com/protocol-buffers/docs/reference/go/faq#enforce-version
Upvotes: 2