I am trying to generate Go code for some Protocol Buffers as well as a gRPC service.
In the past I have used https://github.com/golang/protobuf
with a generate command that looked something like this:
//go:generate protoc --proto_path=. --go-out=. --go_opt=paths=source_relative <file>.proto
//go:generate protoc --proto_path=. --go_grpc_out=. --go_grpc_opt=paths=source_relative <file>.proto
This method worked just fine, but the repo has since been superceded by google.golang.org/protobuf
and google.golang.org/grpc
.
From what I've read, this was an intentional split to separate the protobuf and gRPC project release cycles.
Using the new repositories, I installed the tools like this:
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
Both tools are installed, and are visible on the path. The problem that I'm encountering is that protoc
or protoc-gen-go
is looking for the older tool - protoc-gen-go_grpc
. Note the underscore.
I have been reading all the documentation and Github issues that I can find, and haven't yet been able to figure out how I am meant to use the new protoc-gen-go-grpc
. Note the dash.
$ echo $GOPATH
/Users/<username>/dev/go
$ echo $GOBIN
/Users/<username>/dev/go/bin
$ which protoc
/opt/homebrew/bin/protoc
$ which protoc-gen-go
/Users/<username>/dev/go/bin/protoc-gen-go
$ which protoc-gen-go_grpc
protoc-gen-go_grpc not found
$ which protoc-gen-go-grpc
/Users/<username>/dev/go/bin/protoc-gen-go-grpc