undefined: grpc.SupportPackageIsVersion7 grpc.ServiceRegistrar

Already they have provided this solution in their documentation here. I had the same issue and here is my solution:

go get -u github.com/golang/protobuf/{proto,protoc-gen-go}
go get -u google.golang.org/grpc
protoc --go_out=plugins=grpc:. *.proto

Here is the explanation if you are not using Go modules:


grpc.SupportPackageIsVersion is used to track the version of the protobuf generated code and is different from the grpc release version.

In short, Your generated GRPC code structure is newer than your google.golang.org/grpc package. So you must update your go grpc package to the new one.

SupportPackageIsVersion7 support after 1.32.0 versions. and they support old versions with go version >= 1.12

to update it you should

  • first, remove the current one, to find where it stored, you can use the echo $PATH command to find out where this file is. then remove it.

  • second, install the new one, for installing it you can run this command.

    go install google.golang.org/grpc/cmd/protoc-gen-go-grpc

    Note If you have any problem to get it, use this command instead,

    go get -u github.com/golang/protobuf/protoc-gen-go

after the update, you must edit your go.mod file.

change this line:

google.golang.org/grpc v1.21.1

to

google.golang.org/grpc v1.32.0// or newer

Note: You can find last releases from this URL

You can find versions supports of the package at the end of rpc_util.go in constants.

something like this:

const (
    SupportPackageIsVersion3 = true
    SupportPackageIsVersion4 = true
    SupportPackageIsVersion5 = true
    SupportPackageIsVersion6 = true
    SupportPackageIsVersion7 = true
)

The gist of this error is that the version of binary used to generate the code isn't compatible with the current version of code. A quick and easy solution would be to try updating the protoc-gen-go compiler and the gRPC library to the latest version.

go get -u github.com/golang/protobuf/protoc-gen-go

then regen the proto

heres a link to a reddit thread that discusses the issue