This is protobuf code generation for micro. We use protoc-gen-micro to reduce boilerplate code.
We previously maintained a fork of golang/protobuf to include the micro plugin but have since moved to protoc-gen-micro.
go get github.com/micro/protoc-gen-micro
Also required:
Define your service as greeter.proto
syntax = "proto3";
service Greeter {
rpc Hello(Request) returns (Response) {}
}
message Request {
string name = 1;
}
message Response {
string msg = 1;
}
Generate the code
protoc --proto_path=$GOPATH/src:. --micro_out=. --go_out=. greeter.proto
Your output result should be:
./
greeter.proto # original protobuf file
greeter.pb.go # auto-generated by protoc-gen-go
greeter.micro.go # auto-generated by protoc-gen-micro
The micro generated code includes clients and handlers which reduce boiler plate code
protoc-gen-micro is a liberal reuse of protoc-gen-go hence we maintain the original license