go get google.golang.org/grpc 解决办法汇总

go get -u 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: d
dial tcp 216.239.37.1:443: connectex: A connection ()

解决方法(在src目录下)

1.D:\GoProject\src>git clone https://github.com/grpc/grpc-go ./google.golang.org/grpc
2.D:\GoProject\src>git clone https://github.com/golang/net.git ./golang.org/x/net
3.git clone https://github.com/google/go-genproto.git ./google.golang.org/genproto
4.git clone https://github.com/golang/text.git ./golang.org/x/text
5.最后 go install google.golang.org/grpc

测试安装

基本上go install没有提示错误,grpc就算安装好了,我们现在拿grpc里的example来测试下
// 先启动server
D:\GoProject\src>go run google.golang.org/grpc/examples/helloworld/greeter_server/main.go
2020/05/13 11:50:11 Received: world
//后启动client
D:\GoProject\src>go run google.golang.org/grpc/examples/helloworld/greeter_client/main.go
2020/05/13 11:50:12 Greeting: Hello world

你可能感兴趣的:(golang,go,golang)