分享
mac osx grpc-go 开发环境搭建
罚舞 · · 1158 次点击 · · 开始浏览这是一个创建于 的文章,其中的信息可能已经有所发展或是发生改变。
0. 先决必要条件:golang 1.9+,这里略过。
1. quick install
来自这里 https://github.com/grpc/homebrew-grpc
brew tap grpc/grpc
brew install --with-plugins grpc
2. 从代码编译安装
2.1 protobuf install
brew install autoconf automake libtool curl make g++ unzip
下载[protobuf](https://github.com/protocolbuffers/protobuf/releases/latest)
tar -zxvf protobuf-x.x.x
cd protobuf-x.x.x
./configure --prefix=/usr
make
make check
sudo make install
protoc --version
- 以上是基于release版本变异安装的过程。如果直接git clone master分支,可能还需要先安装xcode,之后:
sudo xcode-select --install - 更详细步骤参考github项目protobuf
2.2 grpc-go install
官方安装命令:go get google.golang.org/grpc
然而一般都会失败报错:
https fetch failed: Get https://google.golang.org/grpc?go-get=1: net/http: TLS handshake timeout
原因你懂的。
其实是这个代码已经转移到github上面了,但是代码里面的包依赖还是没有修改,还是google.golang.org这种,
所以:
git clone https://github.com/grpc/grpc-go.git $GOPATH/src/google.golang.org/grpc
git clone https://github.com/golang/net.git $GOPATH/src/golang.org/x/net
git clone https://github.com/golang/text.git $GOPATH/src/golang.org/x/text
go get -u -v github.com/golang/protobuf/{proto,protoc-gen-go}
git clone https://github.com/google/go-genproto.git $GOPATH/src/google.golang.org/genproto
cd $GOPATH/src/
go install google.golang.org/grpc
- 这一部分参考,实测可行:https://www.jianshu.com/p/dba4c7a6d608
3. 总结
至此,grpc-go mac 开发环境ready!后续将继续分享grpc使用笔记,下篇计划:
- grpc-go使用入门级示例。
有疑问加站长微信联系(非本文作者)
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
关注微信1158 次点击
上一篇:go包管理器
添加一条新回复
(您需要 后才能回复 没有账号 ?)
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码` - 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传
收入到我管理的专栏 新建专栏
0. 先决必要条件:golang 1.9+,这里略过。
1. quick install
来自这里 https://github.com/grpc/homebrew-grpc
brew tap grpc/grpc
brew install --with-plugins grpc
2. 从代码编译安装
2.1 protobuf install
brew install autoconf automake libtool curl make g++ unzip
下载[protobuf](https://github.com/protocolbuffers/protobuf/releases/latest)
tar -zxvf protobuf-x.x.x
cd protobuf-x.x.x
./configure --prefix=/usr
make
make check
sudo make install
protoc --version
- 以上是基于release版本变异安装的过程。如果直接git clone master分支,可能还需要先安装xcode,之后:
sudo xcode-select --install - 更详细步骤参考github项目protobuf
2.2 grpc-go install
官方安装命令:go get google.golang.org/grpc
然而一般都会失败报错:
https fetch failed: Get https://google.golang.org/grpc?go-get=1: net/http: TLS handshake timeout
原因你懂的。
其实是这个代码已经转移到github上面了,但是代码里面的包依赖还是没有修改,还是google.golang.org这种,
所以:
git clone https://github.com/grpc/grpc-go.git $GOPATH/src/google.golang.org/grpc
git clone https://github.com/golang/net.git $GOPATH/src/golang.org/x/net
git clone https://github.com/golang/text.git $GOPATH/src/golang.org/x/text
go get -u -v github.com/golang/protobuf/{proto,protoc-gen-go}
git clone https://github.com/google/go-genproto.git $GOPATH/src/google.golang.org/genproto
cd $GOPATH/src/
go install google.golang.org/grpc
- 这一部分参考,实测可行:https://www.jianshu.com/p/dba4c7a6d608
3. 总结
至此,grpc-go mac 开发环境ready!后续将继续分享grpc使用笔记,下篇计划:
- grpc-go使用入门级示例。