社区微信群开通啦,扫一扫抢先加入社区官方微信群
社区微信群
1、安装Protobuf
在 https://github.com/google/protobuf/releases
下载
把解压后的 protoc.exe 放入到 GOPATHBIN 中
2、安装grpc
Git clone https://github.com/grpc/grpc-go
将grpc-go更名为grpc放入到google.golang.org中,完整路径如下
D:gopathsrcgoogle.golang.orggrpc
3、安装Genproto
Git clone https://github.com/google/go-genproto
将clone下来的文件夹更名为genproto,放到google.golang.org下,完整路径如下
D:gopathsrcgoogle.golang.orggenproto
4、下载text包
git clone https://github.com/golang/text.git
5、下载net包
git clone https://github.com/golang/net.git
6、安装proto
go get -u github.com/golang/protobuf/proto
7、安装protoc-gen-go
go get -ugithub.com/golang/protobuf/protoc-gen-go
8、验证
进入下列目录
srcgoogle.golang.orggrpcexampleshelloworld>
执行命令生成代码helloworld.pb.go
protoc -I ./helloworld--go_out=plugins=grpc:./helloworld ./helloworldhelloworld.proto
进入greeter_server下执行
go run main.go
进入greeter_client下执行
go run main.go
2018/06/19 11:29:25 Greeting: Hello world
Process finished with exit code 0
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!