MAC下使用gRPC开发的环境安装

第一步:安装brew

brew -v

先用这个命令确认一下你是不是有安装过了,如果没有安装过就用下面这个命令

ruby -e $(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)

安装brew

第二步:安装protobuf

brew install automake

brew install libtool

brew install protobuf

就是利用brew下载安装了。protobuf就是我们想要的,另外两个是依赖库

第三步:安装gRPC

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 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

安装成功后,在你的gopath/bin下会多一个protoc-gen-go文件

第四步:把gopath/bin放到你的path环境变量中去。

转:https://www.cnblogs.com/quickcodes/p/5398709.html

第五步:生成你要的pb文件

protoc --go_out=plugins=grpc:./ *.proto

这命令的意思是生成go的输出文件,使用插件grpc(因为我们这里要用这个来进行grpc所以要加这个插件,如果不加这个,导出的文件就没有grpc的服务了)

第六步:做一个例子

https://blog.csdn.net/lk2684753/article/details/84436190

网上的例子很多,我就不重新写了,环境好了,怎么搞都可以

https://github.com/buguang01/bige

你可能感兴趣的:(Golang)