protoc-gen-gorpc
protocol file generation tool for gorpc
Install
-
First of all, you need to install the protoc tool, protoc
-
Then you need to install the protoc-gen-go tool
go get -u github.com/golang/protobuf/protoc-gen-go
-
Run the following command in the terminal to install protoc-gen-gorpc
go get -u -v github.com/lubanproj/protoc-gen-gorpc
Quick Start
- Writing a protocol file, for example :
syntax = "proto3";
service Greeter {
rpc Hello(Request) returns (Response) {}
}
message Request {
string name = 1;
}
message Response {
string msg = 1;
}
-
Run the following command to generate the pb.go file
protoc --gorpc_out=plugin:. greeter.proto
A file greeter.pb.go is generated.