This is a creation in Article, where the information may have evolved or changed.
To get Protoc to use plugins, you need to do the following:
Place the plugin binary somewhere in the PATH and give it the name "Protoc-gen-name" (replacing "name" with the name of yo ur plugin).
If you then invoke Protoc with the Parameter–name_out=out_dir (again, replace "name" with your plugin ' s name), Protoc wil L Invoke your plugin to generate the output, which'll be is placed in Out_dir.
Place the plugin binary anywhere, with any name, and pass The–plugin parameter to Protoc to direct it to your plugin like So
Protoc--plugin=protoc-gen-name=path/to/mybinary--name_out=out_dir
On Windows, make sure to include the. exe suffix:
Protoc--plugin=protoc-gen-name=path/to/mybinary.exe--name_out=out_dir
Reference: Https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.compiler.plugin
The plugin commands that generate the GRPC code for Go are:
protoc --go_out=plugins=grpc,import_path=mypackage:. *.proto
Here through the--name_out, you can know is the need to find Protoc-gen-name plug-ins, that is, protoc-gen-go plug-ins.
Https://github.com/golang/protobuf/blob/master/protoc-gen-go/grpc/grpc.go as a plugin.