在Windows中安装grpc
alvin2018 · · 4225 次点击 · · 开始浏览1、安装Protobuf
在 https://github.com/google/protobuf/releases
下载
把解压后的 protoc.exe 放入到 GOPATH\BIN 中
2、安装grpc
Git clone https://github.com/grpc/grpc-go
将grpc-go更名为grpc放入到google.golang.org中,完整路径如下
D:\gopath\src\google.golang.org\grpc
3、安装Genproto
Git clone https://github.com/google/go-genproto
将clone下来的文件夹更名为genproto,放到google.golang.org下,完整路径如下
D:\gopath\src\google.golang.org\genproto
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、验证
进入下列目录
src\google.golang.org\grpc\examples\helloworld>
执行命令生成代码helloworld.pb.go
protoc -I ./helloworld--go_out=plugins=grpc:./helloworld ./helloworld\helloworld.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
有疑问加站长微信联系(非本文作者)
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
关注微信- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码` - 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传
收入到我管理的专栏 新建专栏
1、安装Protobuf
在 https://github.com/google/protobuf/releases
下载
把解压后的 protoc.exe 放入到 GOPATH\BIN 中
2、安装grpc
Git clone https://github.com/grpc/grpc-go
将grpc-go更名为grpc放入到google.golang.org中,完整路径如下
D:\gopath\src\google.golang.org\grpc
3、安装Genproto
Git clone https://github.com/google/go-genproto
将clone下来的文件夹更名为genproto,放到google.golang.org下,完整路径如下
D:\gopath\src\google.golang.org\genproto
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、验证
进入下列目录
src\google.golang.org\grpc\examples\helloworld>
执行命令生成代码helloworld.pb.go
protoc -I ./helloworld--go_out=plugins=grpc:./helloworld ./helloworld\helloworld.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