go安装grpc及依赖( unrecognized import path "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)

报这个错误说明缺少grpc这个包

1、新建grpc存放路径

    $ mkdir $GOPATH/src/google.golang.org

2、进入文件夹,下载grpc包

    $ cd $GOPATH/src/google.golang.org
    $ git clone https://github.com/grpc/grpc-go.git

3、重命名 grpc-go 为 grpc

    $ mv grpc-go grpc

4、安装
    $ go install grpc
    报错:google.golang.org/genproto/googleapis/rpc/status
    提示缺少google.golang.org/genproto这个包,别慌,看我操作就完事了
    

5、进入文件夹,下载genproto包

    $ cd $GOPATH/src/google.golang.org
    $ git clone https://github.com/googleapis/go-genproto.git

6、重命名 go-genproto 为 genproto

    $ mv go-genproto genproto

7、安装
    $ go install grpc

8、成功
  1. 请注意,golang.org/x/net  和 google.golang.org/grpc 报错下载包的存放路径问题
已标记关键词 清除标记
<div class="post-text" itemprop="text"> <p>So I am trying to install my Go app's dependencies on my Raspberry 3/Raspbian system with "go get" and running into the following when trying to install gRPC for Go:</p> <pre><code>[pi@raspberrypi-1 camera-service] 17:32:28 % 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: lookup google.golang.org on 192.168.1.1:53: read udp 192.168.1.64:33524->192.168.1.1:53: i/o timeout) </code></pre> <p>Meanwhile I am able to install other (non-google.golang.org) dependencies (for example go get github.com/asaskevich/EventBus) just fine. </p> <p>To me this looks a DNS problem -- 192.168.1.1 is my router, 192.168.1.64 is my RPi. However I can resolve the address just fine:</p> <pre><code>[pi@raspberrypi-1 camera-service] 17:32:52 % host google.golang.org google.golang.org is an alias for golang.org. golang.org has address 216.58.209.145 golang.org has IPv6 address 2a00:1450:400f:804::2011 golang.org mail is handled by 1 aspmx.l.google.com. golang.org mail is handled by 2 alt2.aspmx.l.google.com. golang.org mail is handled by 2 alt1.aspmx.l.google.com. golang.org mail is handled by 2 alt3.aspmx.l.google.com. </code></pre> <p>This is weird. Also I have installed the same packages on another system np.</p> <p>My environment is</p> <pre><code>- Go 1.8.3, installed from prebuilt ARM6 binary - export GOROOT="/usr/local/go" - export GOPATH="/home/pi/go" </code></pre> </div>
©️2020 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页