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>
執(zhí)行命令生成代碼helloworld.pb.go
protoc -I ./helloworld--go_out=plugins=grpc:./helloworld ./helloworld\helloworld.proto
進入greeter_server下執(zhí)行
go run main.go
進入greeter_client下執(zhí)行
go run main.go
2018/06/19 11:29:25 Greeting: Hello world
Process finished with exit code 0