grpc安装方式:

go get google.golang.org/grpc

使用这个命令会报如下错误

package google.golang.org/grpc: unrecognized import path "google.golang.org/grpc
" (https fetch: Get https://google.golang.org/grpc?go-get=1: dial tcp 119.28.87.
227:443: connectex: A connection attempt failed because the connected party did
not properly respond after a period of time, or established connection failed be
cause connected host has failed to respond.)

在网上搜索有很多人说是被墙了;但是本人挂了vpn还是报同样的错误; 替代的安装方式如下:

//$GOPATH为你电脑上golang的环境变量;可通过命令“go env”查找

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

测试:

cd src\google.golang.org\grpc\examples\helloworld
//运行服务端
go run greeter_server\main.go
//运行客户端
go run greeter_client\main.go

参考地址: 1. grpc文档中文版地址