By default, gRPC uses protocol buffers as the Interface Definition Language (IDL) for describing both the service interface and the structure of the payload messages.
1. Install the gRPC runtime
go get google.golang.org/grpc
2. Install the protocol buffer compiler and runtime with gRPC
$ go get -a github.com/golang/protobuf/protoc-gen-goOr in windows, you can install protoc-3.0.0-beta-3-win32.zip
3. Define a service and generate gRPC code
Edit a helloworld.proto file under ./helloworld folder.
The generated code will be in the same folder as .proto file
Note:
The first parameter proto_path(or -I) must be an exact prefix of the .proto file names
The second parameter refers to the .proto file
The third parameter refers to the language of the generated code
$ protoc -I helloworld helloworld/helloworld.proto --go_out=plugins=grpc:helloworld
Reference:
http://www.grpc.io/docs/
No comments:
Post a Comment