This is a creation in Article, where the information may have evolved or changed.
GRPC is a high-performance, general-purpose, open-source RPC framework developed by Google primarily for mobile applications and based on the HTTP/2 protocol standards, developed based on the PROTOBUF (Protocol buffers) serialization protocol, and supports many development languages. GRPC provides an easy way to precisely define services and automatically generate a highly reliable client function library for iOS, Android, and background support services. Clients take advantage of advanced streaming and linking capabilities to help conserve bandwidth, reduce the number of TCP links, conserve CPU usage, and battery life.
The example you see here is from: Grpc in 3 minutes (Go)
Http://www.grpc.io/docs/installation/go.html
Get the code for the client and server side separately as follows:
$ go get -u github.com/grpc/grpc-common/go/greeter_client$ go get -u github.com/grpc/grpc-common/go/greeter_server
Powerful IDL features
GRPC uses PROTOBUF to define services, PROTOBUF is a data serialization protocol developed by Google (similar to XML, JSON, Hessian). Protobuf is capable of serializing data and is widely used in data storage, communication protocols, and so on.
In this example, the IDL file uses this: Https://github.com/grpc/grpc-common/blob/master/protos/helloworld.proto
We are here directly with go files that have been produced based on this proto file: Https://github.com/grpc/grpc-common/blob/master/go/helloworld/helloworld.pb.go We don't use PROTOC tools here.
Due to the wall, some of our dependent package files can be downloaded in the following ways:
On GitHub you can find the source code, download and copy to the corresponding directory:
GOOGLE.GOLANG.ORG/GRPC corresponding code address in: Https://github.com/grpc/grpc-go
Google.golang.org/cloud/compute/metadata corresponding code address in: Https://github.com/GoogleCloudPlatform/gcloud-golang
Golang.org/x/oauth2 corresponding code address in: Https://github.com/golang/oauth2
Golang.org/x/net/context corresponding code address in: Https://github.com/golang/net
The source code for these packages can also be downloaded via http://gopm.io/or http://golangtc.com/download/package.
Go get–a This command, the –a parameter is the go install parameter, not the go get parameter.
Reference: HTTPS://GITHUB.COM/ASTAXIE/BUILD-WEB-APPLICATION-WITH-GOLANG/BLOB/MASTER/ZH/01.3.MD
Server-side code
Note I'm here to make it easier to view, increase each request to print one message:
Client code: