I am having a hard time figuring out
protoc command and go plugin.
What is the different between:
protoc \ # Directory where you want the compiler to write your Go output. --go_out=. # vs ? --go_opt=paths=source_relative # vs ? --go-grpc_out=. # vs ? --go-grpc_opt=paths=source_relative
why even have
Can you shade some light on protoc – the doc do not stay anything about
protoc -h do not even list go as an OUT_DIR?
Note: I install using this doc
why even have –go_out?
So, the thing to understand here is that gRPC is not the same as Protocol Buffers, gRPC uses Protocol Buffers but there are other frameworks that are using them as well. So we need to generate both.
Now, in order to generate the Protocol buffer related code, you need to use
--go_out as you mentioned. but for the gRPC code you need to use
and –go-grpc_opt generate _grpc.pb.go file
Can you shade some light on protoc – the doc do not stay anything about –go-grpc_opt?
Then, before the generation of code you can pass some options and that’s what
--go-grpc_opt are for. The first one passes options for Protobuf generation and the second one for gRPC generation. Options are pretty obscure, and there is not official list of all of them, but you used
source_relative (which tell protoc to use relative paths) for path and there is also the
module option (which help protoc know the go module name to generate in proper folder)
And and protoc -h do not even list go as an OUT_DIR?
And finally, protoc doesn’t officially support Go as output, you need to install an external plugin and that’s why
protoc -h doesn’t show
Hope that helps.
Answered By – Clément Jean
Answer Checked By – Cary Denson (GoLangFix Admin)