golang安装gRpc 报错
golang安装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 216.239.37.1:443: i/o timeout)
原因是这个代码已经转移到github上面了,但是代码里面的包依赖还是没有修改,还是google.golang.org这种,
所以不能使用go get的方式安装,正确的安装方式:
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
继续报错:
google.golang.org/grpc/internal/channelz/types_linux.go:26:2: cannot find package "golang.org/x/sys/unix" in any of:
/usr/local/go/src/golang.org/x/sys/unix (from $GOROOT)
/go/src/golang.org/x/sys/unix (from $GOPATH)
解决方案,依然采用github的地址。
git clone https://github.com/golang/sys.git $GOPATH/src/golang.org/x/sys
posted on 2020-01-07 17:10 ExplorerMan 阅读(1278) 评论(0) 编辑 收藏 举报