14

https://github.com/golang/protobuf

protoc-gen-go is a plugin in protoc which generates go bindings for the input proto definition.

protoc-gen-go also has a plugin framework for which grpc is a plugin plugin https://github.com/golang/protobuf/tree/master/protoc-gen-go/grpc

$ protoc ./helloworld.proto --go_out=plugins=grpc:.

is it possible that that i write my own plugin and invoke it along with grpc plugin?

$ protoc ./helloworld.proto --go_out=plugins=grpc+myplugin:.

do i need to mandatory build my plugin into protoc-gen-go ? if no, then how will the protoc-gen-go find myplugin ?

weima
  • 4,653
  • 6
  • 34
  • 55
  • Some starting point could be found with this issue: https://github.com/golang/protobuf/issues/147 – yageek Sep 13 '17 at 15:10

1 Answers1

7

protoc-gen-go is a protoc plugin. I have written an example of another protoc plugin below for custom work. I've also used plugins which invoke other plugins.

https://github.com/drekle/protoc-gen-goexample

Protoc finds these plugins by name protoc-gen-<PLUGIN_NAME> which it expects to be a binary in your path and will interpret the args it is passed, for example --<PLUGIN_NAME>_out instead of --go_out for your plugin

Derek Lemon
  • 121
  • 1
  • 5