This is a created article in which the information may have evolved or changed.
Installing GRPC
Use the following command for GRPC installation:
go get google.golang.org/grpc
Installing Protocol buffers v3
Install the protocol compiler used to generate the GRPC service code. The easiest way to do this is to download a binary compression package in https://github.com/google/protobuf/releases. Add the environment variable after decompression, as follows:
export PATH=$PATH:执行路径 (linux下)set PATH=%PATH%;执行路径 (windows下)
Install the Protocol plug-in by executing the following command:
go get -u github.com/golang/protobuf/proto
go get -u github.com/golang/protobuf/protoc-gen-go
New file "Helloworld.proto", fill in the following content:
syntax = "proto3";package helloworld;// 服务端定义service Greeter {// 服务端返馈信息方法rpc SayHello (HelloRequest) returns (HelloReply) {}}// 包含用户名的请求信息message HelloRequest {string name = 1;}// 服务端响应信息message HelloReply {string message = 1;}