# grpc-demo **Repository Path**: liuhedev/grpc-demo ## Basic Information - **Project Name**: grpc-demo - **Description**: No description available - **Primary Language**: Go - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-11-11 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README 参考:https://segmentfault.com/a/1190000019216566 # 1、环境配置 (1)安装 protobuf环境 可以使用protoc命令,产生序列化和反序列化的代码,但无go相关代码 (2)安装 protoc-gen-go 它是Go的protoc编译插件,可以产生go相关代码, 除上述序列化和反序列化代码之外, 还增加了一些通信公共库。 (3)安装 grpc-go 库 grpc-go包含了Go的grpc库。 (4)其它库的安装 git clone https://github.com/golang/protobuf $GOPATH/src/github.com/golang/protobuf git clone https://github.com/protocolbuffers/protobuf-go $GOPATH/src/google.golang.org/protobuf # 2、流程 (1)使用protoc定义服务接口 (2)生成grpc文件 protoc -I. --go_out=plugins=grpc:/Users/liuhe/go/src/liuhe.go/grpc user.proto (3)服务端集成协议 (4)客户端集成协议 (5)运行服务 go run server.go go run client.go 参考:https://segmentfault.com/a/1190000019216566