Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

我设置了GOPROXY还是无法下载 #29

Closed
yjbdsky opened this issue Sep 28, 2019 · 37 comments
Closed

我设置了GOPROXY还是无法下载 #29

yjbdsky opened this issue Sep 28, 2019 · 37 comments

Comments

@yjbdsky
Copy link

yjbdsky commented Sep 28, 2019

go env -w GOPROXY=https://goproxy.cn,direct
➜ ~ go env |grep GOPROXY
GOPROXY="https://goproxy.cn,direct"
➜ ~ go get cloud.google.com/go/compute/metadata
package cloud.google.com/go/compute/metadata: unrecognized import path "cloud.google.com/go/compute/metadata" (https fetch: Get https://cloud.google.com/go/compute/metadata?go-get=1: dial tcp 216.58.200.238:443: i/o timeout)

@aofei
Copy link
Member

aofei commented Sep 28, 2019

你好,你把 go env -w GO111MODULE=on 这条命了也执行一遍试试看。

@yjbdsky
Copy link
Author

yjbdsky commented Sep 28, 2019

提示下载了,,但gopath里找不到这个包,,,

@yjbdsky
Copy link
Author

yjbdsky commented Sep 28, 2019

3Q,,找到了在pkg/mod中

@aofei
Copy link
Member

aofei commented Sep 28, 2019

传统的 $GOPATH/src 现在已经不用了,然后就是 Go modules 的缓存虽然目前还暂时存放到 $GOPATH/pkg/mod 中,但是在未来就有可能移动到 $GOCACHE/mod 中了,所以建议你应该尽可能地摆脱 GOPATH 才对。如果老哥你感兴趣有时间想深入了解 Go modules 的话,建议老哥去看一下这周四我在【Go 夜读】做的一期比较深入的在线直播分享,包含了 Go modules 的由来之类的,录屏地址之类的详见:talkgo/night#468

@yjbdsky
Copy link
Author

yjbdsky commented Sep 28, 2019

不是,我是在把原来的glide的项目转成go modules项目,转换的时候还是得访问外面,不过我找了个代理搞定了,不过出现如下错误了:
go: k8s.io/[email protected] requires
k8s.io/[email protected]: reading http://goproxy.cn/k8s.io/api/@v/v0.0.0.mod: 404 Not Found

@aofei
Copy link
Member

aofei commented Sep 28, 2019

从 dep 或者 glide 之类的迁移到 Go modules 的时候的确是不会走 Go module proxy 的,这是个 Bug,会在 Go 1.14 中得到修复,我正在努力,详见:golang/go#33767

然后关于 k8s 那个错误,那个就是 k8s 的一个坑了,很多人在用 Go moduels 的时候都遇见过,这是因为 kubernetes/kubernetes 不允许用户将自己作为一个库来使用,具体你可以看一下 kubernetes/kubernetes#80316 (comment) 这个回复。

@yjbdsky
Copy link
Author

yjbdsky commented Sep 28, 2019

好的,谢谢

@preminem
Copy link

从 dep 或者 glide 之类的迁移到 Go modules 的时候的确是不会走 Go module proxy 的,这是个 Bug,会在 Go 1.14 中得到修复,我正在努力,详见:golang/go#33767

然后关于 k8s 那个错误,那个就是 k8s 的一个坑了,很多人在用 Go moduels 的时候都遇见过,这是因为 kubernetes/kubernetes 不允许用户将自己作为一个库来使用,具体你可以看一下 kubernetes/kubernetes#80316 (comment) 这个回复。

那现在从dep迁移到modules现在有没有什么好的解决方案吗?使用go mod init之后没走代理,但是go.mod文件生成成功,之后执行go mod download依然失败。

@aofei
Copy link
Member

aofei commented Oct 11, 2019

你好,@preminem

现在从 dep 迁移到 Go modules 若想走 Go module proxy 的话,有一个变通办法,就是先想办法创建一个空的 go.mod 文件,比如:

module example.com/foo/bar

go 1.13

然后再执行 go mod tidy,此时 go 还是会从你的 dep 的 Gopkg.lock 文件中读取、解析并推算以补充 go.mod 文件剩下的内容,此时会走 Go module proxy 的。

@preminem
Copy link

你好,@preminem

现在从 dep 迁移到 Go modules 若想走 Go module proxy 的话,有一个变通办法,就是先想办法创建一个空的 go.mod 文件,比如:

module example.com/foo/bar

go 1.13

然后再执行 go mod tidy,此时 go 还是会从你的 dep 的 Gopkg.lock 文件中读取、解析并推算以补充 go.mod 文件剩下的内容,此时会走 Go module proxy 的。

谢谢你的回答,但是我在执行go mod tidy时虽然下载包没有问题,但是出现了大量以下形式的错误
malformed module path "<我项目的路径>": missing dot in first path element,你知道这是什么原因吗?

@aofei
Copy link
Member

aofei commented Oct 11, 2019

@preminem

当启用了 Go modules 后,代码里所有的 import path 必须是以某个 module path 为前缀。通常一个 module path 的第一个部分都是一个主机,比如“github.com/goproxy/goproxy“这个 module path 的主机就是”github.com“,这样 go 就知道该去哪个地方寻找目标模块了。所以“missing dot in first path element”这个错误指的意思就是 go 没有找到它期望的那个主机。

但是,如果你用的目标模块的 module path 是一个类似”foobar“这种不包含主机的,或者主机不是在互联网的,那么通常我们需要用到 replace 指令,比如下面这个 go.mod 文件:

module example.com/foo/bar

go 1.13

require apple v1.0.0

replace apple => ../apple

它的意思就是,当前这个项目(aka 当前这个 module path 为“example.com/foo/bar”的模块)需要依赖一个 module path 为“apple”的模块,并且通过“replace”指令告诉了 go 这个模块的位置在当前项目的上一级目录的一个叫做“apple”的目录下。通过类似这样的做法,就可以解决你的那个问题了。

@liesauer
Copy link

+1,为啥还是去连了golang.org?

Installing 18 tools at /Users/imac/go/bin
  gocode
  gopkgs
  go-outline
  go-symbols
  guru
  gorename
  gotests
  gomodifytags
  impl
  fillstruct
  goplay
  godoctor
  dlv
  gocode-gomod
  godef
  goimports
  golint
  gopls

Installing github.com/mdempsky/gocode FAILED
Installing github.com/uudashr/gopkgs/cmd/gopkgs SUCCEEDED
Installing github.com/ramya-rao-a/go-outline FAILED
Installing github.com/acroca/go-symbols FAILED
Installing golang.org/x/tools/cmd/guru FAILED
Installing golang.org/x/tools/cmd/gorename FAILED
Installing github.com/cweill/gotests/... FAILED
Installing github.com/fatih/gomodifytags SUCCEEDED
Installing github.com/josharian/impl FAILED
Installing github.com/davidrjenni/reftools/cmd/fillstruct SUCCEEDED
Installing github.com/haya14busa/goplay/cmd/goplay SUCCEEDED
Installing github.com/godoctor/godoctor FAILED
Installing github.com/go-delve/delve/cmd/dlv SUCCEEDED
Installing github.com/stamblerre/gocode FAILED
Installing github.com/rogpeppe/godef SUCCEEDED
Installing golang.org/x/tools/cmd/goimports FAILED
Installing golang.org/x/lint/golint FAILED
Installing golang.org/x/tools/gopls FAILED

12 tools failed to install.

gocode:
Error: Command failed: /usr/local/go/bin/go get -v github.com/mdempsky/gocode
go: finding github.com/mdempsky/gocode latest
Fetching https://golang.org/x/tools/go/gcexportdata?go-get=1
https fetch failed: Get https://golang.org/x/tools/go/gcexportdata?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x/tools/go?go-get=1
https fetch failed: Get https://golang.org/x/tools/go?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x/tools?go-get=1
https fetch failed: Get https://golang.org/x/tools?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x?go-get=1
https fetch failed: Get https://golang.org/x?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org?go-get=1
https fetch failed: Get https://golang.org?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
build github.com/mdempsky/gocode: cannot load golang.org/x/tools/go/gcexportdata: cannot find module providing package golang.org/x/tools/go/gcexportdata
go: finding github.com/mdempsky/gocode latest
Fetching https://golang.org/x/tools/go/gcexportdata?go-get=1
https fetch failed: Get https://golang.org/x/tools/go/gcexportdata?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x/tools/go?go-get=1
https fetch failed: Get https://golang.org/x/tools/go?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x/tools?go-get=1
https fetch failed: Get https://golang.org/x/tools?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x?go-get=1
https fetch failed: Get https://golang.org/x?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org?go-get=1
https fetch failed: Get https://golang.org?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
build github.com/mdempsky/gocode: cannot load golang.org/x/tools/go/gcexportdata: cannot find module providing package golang.org/x/tools/go/gcexportdata

go-outline:
Error: Command failed: /usr/local/go/bin/go get -v github.com/ramya-rao-a/go-outline
go: finding github.com/ramya-rao-a/go-outline latest
Fetching https://golang.org/x/tools/go/buildutil?go-get=1
https fetch failed: Get https://golang.org/x/tools/go/buildutil?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x/tools/go?go-get=1
https fetch failed: Get https://golang.org/x/tools/go?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x/tools?go-get=1
https fetch failed: Get https://golang.org/x/tools?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x?go-get=1
https fetch failed: Get https://golang.org/x?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org?go-get=1
https fetch failed: Get https://golang.org?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
build github.com/ramya-rao-a/go-outline: cannot load golang.org/x/tools/go/buildutil: cannot find module providing package golang.org/x/tools/go/buildutil
go: finding github.com/ramya-rao-a/go-outline latest
Fetching https://golang.org/x/tools/go/buildutil?go-get=1
https fetch failed: Get https://golang.org/x/tools/go/buildutil?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x/tools/go?go-get=1
https fetch failed: Get https://golang.org/x/tools/go?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x/tools?go-get=1
https fetch failed: Get https://golang.org/x/tools?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x?go-get=1
https fetch failed: Get https://golang.org/x?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org?go-get=1
https fetch failed: Get https://golang.org?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
build github.com/ramya-rao-a/go-outline: cannot load golang.org/x/tools/go/buildutil: cannot find module providing package golang.org/x/tools/go/buildutil

go-symbols:
Error: Command failed: /usr/local/go/bin/go get -v github.com/acroca/go-symbols
Fetching https://golang.org/x/tools/go/buildutil?go-get=1
https fetch failed: Get https://golang.org/x/tools/go/buildutil?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x/tools/go?go-get=1
https fetch failed: Get https://golang.org/x/tools/go?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x/tools?go-get=1
https fetch failed: Get https://golang.org/x/tools?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x?go-get=1
https fetch failed: Get https://golang.org/x?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org?go-get=1
https fetch failed: Get https://golang.org?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
build github.com/acroca/go-symbols: cannot load golang.org/x/tools/go/buildutil: cannot find module providing package golang.org/x/tools/go/buildutil
Fetching https://golang.org/x/tools/go/buildutil?go-get=1
https fetch failed: Get https://golang.org/x/tools/go/buildutil?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x/tools/go?go-get=1
https fetch failed: Get https://golang.org/x/tools/go?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x/tools?go-get=1
https fetch failed: Get https://golang.org/x/tools?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x?go-get=1
https fetch failed: Get https://golang.org/x?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org?go-get=1
https fetch failed: Get https://golang.org?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
build github.com/acroca/go-symbols: cannot load golang.org/x/tools/go/buildutil: cannot find module providing package golang.org/x/tools/go/buildutil

guru:
Error: Command failed: /usr/local/go/bin/go get -v golang.org/x/tools/cmd/guru
Fetching https://golang.org/x/tools/cmd/guru?go-get=1
https fetch failed: Get https://golang.org/x/tools/cmd/guru?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x/tools/cmd?go-get=1
https fetch failed: Get https://golang.org/x/tools/cmd?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x/tools?go-get=1
https fetch failed: Get https://golang.org/x/tools?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x?go-get=1
https fetch failed: Get https://golang.org/x?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org?go-get=1
https fetch failed: Get https://golang.org?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
go get golang.org/x/tools/cmd/guru: unrecognized import path "golang.org/x/tools/cmd/guru" (https fetch: Get https://golang.org/x/tools/cmd/guru?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
Fetching https://golang.org/x/tools/cmd/guru?go-get=1
https fetch failed: Get https://golang.org/x/tools/cmd/guru?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x/tools/cmd?go-get=1
https fetch failed: Get https://golang.org/x/tools/cmd?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x/tools?go-get=1
https fetch failed: Get https://golang.org/x/tools?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x?go-get=1
https fetch failed: Get https://golang.org/x?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org?go-get=1
https fetch failed: Get https://golang.org?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
go get golang.org/x/tools/cmd/guru: unrecognized import path "golang.org/x/tools/cmd/guru" (https fetch: Get https://golang.org/x/tools/cmd/guru?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)

gorename:
Error: Command failed: /usr/local/go/bin/go get -v golang.org/x/tools/cmd/gorename
Fetching https://golang.org/x/tools/cmd/gorename?go-get=1
https fetch failed: Get https://golang.org/x/tools/cmd/gorename?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x/tools/cmd?go-get=1
https fetch failed: Get https://golang.org/x/tools/cmd?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x/tools?go-get=1
https fetch failed: Get https://golang.org/x/tools?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x?go-get=1
https fetch failed: Get https://golang.org/x?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org?go-get=1
https fetch failed: Get https://golang.org?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
go get golang.org/x/tools/cmd/gorename: unrecognized import path "golang.org/x/tools/cmd/gorename" (https fetch: Get https://golang.org/x/tools/cmd/gorename?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
Fetching https://golang.org/x/tools/cmd/gorename?go-get=1
https fetch failed: Get https://golang.org/x/tools/cmd/gorename?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x/tools/cmd?go-get=1
https fetch failed: Get https://golang.org/x/tools/cmd?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x/tools?go-get=1
https fetch failed: Get https://golang.org/x/tools?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x?go-get=1
https fetch failed: Get https://golang.org/x?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org?go-get=1
https fetch failed: Get https://golang.org?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
go get golang.org/x/tools/cmd/gorename: unrecognized import path "golang.org/x/tools/cmd/gorename" (https fetch: Get https://golang.org/x/tools/cmd/gorename?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)

gotests:
Error: Command failed: /usr/local/go/bin/go get -v github.com/cweill/gotests/...
go: finding github.com/cweill/gotests/... latest
Fetching https://github.com?go-get=1
Parsing meta tags from https://github.com?go-get=1 (status code 200)
go get github.com/cweill/gotests/...: no matching versions for query "latest"
go: finding github.com/cweill/gotests/... latest
Fetching https://github.com?go-get=1
Parsing meta tags from https://github.com?go-get=1 (status code 200)
go get github.com/cweill/gotests/...: no matching versions for query "latest"

impl:
Error: Command failed: /usr/local/go/bin/go get -v github.com/josharian/impl
go: finding github.com/josharian/impl latest
Fetching https://golang.org/x/tools/imports?go-get=1
https fetch failed: Get https://golang.org/x/tools/imports?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x/tools?go-get=1
https fetch failed: Get https://golang.org/x/tools?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x?go-get=1
https fetch failed: Get https://golang.org/x?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org?go-get=1
https fetch failed: Get https://golang.org?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
build github.com/josharian/impl: cannot load golang.org/x/tools/imports: cannot find module providing package golang.org/x/tools/imports
go: finding github.com/josharian/impl latest
Fetching https://golang.org/x/tools/imports?go-get=1
https fetch failed: Get https://golang.org/x/tools/imports?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x/tools?go-get=1
https fetch failed: Get https://golang.org/x/tools?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x?go-get=1
https fetch failed: Get https://golang.org/x?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org?go-get=1
https fetch failed: Get https://golang.org?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
build github.com/josharian/impl: cannot load golang.org/x/tools/imports: cannot find module providing package golang.org/x/tools/imports

godoctor:
Error: Command failed: /usr/local/go/bin/go get -v github.com/godoctor/godoctor
go: finding github.com/godoctor/godoctor latest
Fetching https://golang.org/x/tools/go/ast/astutil?go-get=1
Fetching https://golang.org/x/tools/go/loader?go-get=1
https fetch failed: Get https://golang.org/x/tools/go/ast/astutil?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
https fetch failed: Get https://golang.org/x/tools/go/loader?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x/tools/go/ast?go-get=1
Fetching https://golang.org/x/tools/go?go-get=1
https fetch failed: Get https://golang.org/x/tools/go/ast?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
https fetch failed: Get https://golang.org/x/tools/go?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x/tools?go-get=1
https fetch failed: Get https://golang.org/x/tools?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x?go-get=1
https fetch failed: Get https://golang.org/x?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org?go-get=1
https fetch failed: Get https://golang.org?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
build github.com/godoctor/godoctor: cannot load golang.org/x/tools/go/ast/astutil: cannot find module providing package golang.org/x/tools/go/ast/astutil
go: finding github.com/godoctor/godoctor latest
Fetching https://golang.org/x/tools/go/ast/astutil?go-get=1
Fetching https://golang.org/x/tools/go/loader?go-get=1
https fetch failed: Get https://golang.org/x/tools/go/ast/astutil?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
https fetch failed: Get https://golang.org/x/tools/go/loader?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x/tools/go/ast?go-get=1
Fetching https://golang.org/x/tools/go?go-get=1
https fetch failed: Get https://golang.org/x/tools/go/ast?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
https fetch failed: Get https://golang.org/x/tools/go?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x/tools?go-get=1
https fetch failed: Get https://golang.org/x/tools?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x?go-get=1
https fetch failed: Get https://golang.org/x?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org?go-get=1
https fetch failed: Get https://golang.org?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
build github.com/godoctor/godoctor: cannot load golang.org/x/tools/go/ast/astutil: cannot find module providing package golang.org/x/tools/go/ast/astutil

gocode-gomod:
Error: Command failed: /usr/local/go/bin/go get -v -d github.com/stamblerre/gocode
go: finding github.com/stamblerre/gocode latest
Fetching https://golang.org/x/tools/go/packages?go-get=1
https fetch failed: Get https://golang.org/x/tools/go/packages?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x/tools/go?go-get=1
https fetch failed: Get https://golang.org/x/tools/go?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x/tools?go-get=1
https fetch failed: Get https://golang.org/x/tools?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x?go-get=1
https fetch failed: Get https://golang.org/x?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org?go-get=1
https fetch failed: Get https://golang.org?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
build github.com/stamblerre/gocode: cannot load golang.org/x/tools/go/packages: cannot find module providing package golang.org/x/tools/go/packages
go: finding github.com/stamblerre/gocode latest
Fetching https://golang.org/x/tools/go/packages?go-get=1
https fetch failed: Get https://golang.org/x/tools/go/packages?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x/tools/go?go-get=1
https fetch failed: Get https://golang.org/x/tools/go?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x/tools?go-get=1
https fetch failed: Get https://golang.org/x/tools?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x?go-get=1
https fetch failed: Get https://golang.org/x?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org?go-get=1
https fetch failed: Get https://golang.org?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
build github.com/stamblerre/gocode: cannot load golang.org/x/tools/go/packages: cannot find module providing package golang.org/x/tools/go/packages

goimports:
Error: Command failed: /usr/local/go/bin/go get -v golang.org/x/tools/cmd/goimports
Fetching https://golang.org/x/tools/cmd/goimports?go-get=1
https fetch failed: Get https://golang.org/x/tools/cmd/goimports?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x/tools/cmd?go-get=1
https fetch failed: Get https://golang.org/x/tools/cmd?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x/tools?go-get=1
https fetch failed: Get https://golang.org/x/tools?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x?go-get=1
https fetch failed: Get https://golang.org/x?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org?go-get=1
https fetch failed: Get https://golang.org?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
go get golang.org/x/tools/cmd/goimports: unrecognized import path "golang.org/x/tools/cmd/goimports" (https fetch: Get https://golang.org/x/tools/cmd/goimports?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
Fetching https://golang.org/x/tools/cmd/goimports?go-get=1
https fetch failed: Get https://golang.org/x/tools/cmd/goimports?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x/tools/cmd?go-get=1
https fetch failed: Get https://golang.org/x/tools/cmd?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x/tools?go-get=1
https fetch failed: Get https://golang.org/x/tools?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x?go-get=1
https fetch failed: Get https://golang.org/x?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org?go-get=1
https fetch failed: Get https://golang.org?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
go get golang.org/x/tools/cmd/goimports: unrecognized import path "golang.org/x/tools/cmd/goimports" (https fetch: Get https://golang.org/x/tools/cmd/goimports?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)

golint:
Error: Command failed: /usr/local/go/bin/go get -v golang.org/x/lint/golint
Fetching https://golang.org/x/lint/golint?go-get=1
https fetch failed: Get https://golang.org/x/lint/golint?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x/lint?go-get=1
https fetch failed: Get https://golang.org/x/lint?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x?go-get=1
https fetch failed: Get https://golang.org/x?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org?go-get=1
https fetch failed: Get https://golang.org?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
go get golang.org/x/lint/golint: unrecognized import path "golang.org/x/lint/golint" (https fetch: Get https://golang.org/x/lint/golint?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
Fetching https://golang.org/x/lint/golint?go-get=1
https fetch failed: Get https://golang.org/x/lint/golint?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x/lint?go-get=1
https fetch failed: Get https://golang.org/x/lint?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x?go-get=1
https fetch failed: Get https://golang.org/x?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org?go-get=1
https fetch failed: Get https://golang.org?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
go get golang.org/x/lint/golint: unrecognized import path "golang.org/x/lint/golint" (https fetch: Get https://golang.org/x/lint/golint?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)

gopls:
Error: Command failed: /usr/local/go/bin/go get -v golang.org/x/tools/gopls
Fetching https://golang.org/x/tools/gopls?go-get=1
https fetch failed: Get https://golang.org/x/tools/gopls?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x/tools?go-get=1
https fetch failed: Get https://golang.org/x/tools?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x?go-get=1
https fetch failed: Get https://golang.org/x?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org?go-get=1
https fetch failed: Get https://golang.org?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
go get golang.org/x/tools/gopls: unrecognized import path "golang.org/x/tools/gopls" (https fetch: Get https://golang.org/x/tools/gopls?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
Fetching https://golang.org/x/tools/gopls?go-get=1
https fetch failed: Get https://golang.org/x/tools/gopls?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x/tools?go-get=1
https fetch failed: Get https://golang.org/x/tools?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org/x?go-get=1
https fetch failed: Get https://golang.org/x?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
Fetching https://golang.org?go-get=1
https fetch failed: Get https://golang.org?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
go get golang.org/x/tools/gopls: unrecognized import path "golang.org/x/tools/gopls" (https fetch: Get https://golang.org/x/tools/gopls?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)


@aofei
Copy link
Member

aofei commented Oct 12, 2019

@liesauer

这个是明显的 Go module proxy 没有在工作呢,而且似乎是连 Go modules 都没有被启用。

是不是设置错了 GOPROXY 环境变量?或者 GO111MODULE 环境变量没有设置为 on?或者你的 IDE 覆盖了这两个环境变量的其中一个?目前我知道的是有些 IDE 比如 GoLand 会覆盖着两个环境变量,还有就是 vim-go 会选择性地调整 GO111MODULE

@preminem
Copy link

@preminem

当启用了 Go modules 后,代码里所有的 import path 必须是以某个 module path 为前缀。通常一个 module path 的第一个部分都是一个主机,比如“github.com/goproxy/goproxy“这个 module path 的主机就是”github.com“,这样 go 就知道该去哪个地方寻找目标模块了。所以“missing dot in first path element”这个错误指的意思就是 go 没有找到它期望的那个主机。

但是,如果你用的目标模块的 module path 是一个类似”foobar“这种不包含主机的,或者主机不是在互联网的,那么通常我们需要用到 replace 指令,比如下面这个 go.mod 文件:

module example.com/foo/bar

go 1.13

require apple v1.0.0

replace apple => ../apple

它的意思就是,当前这个项目(aka 当前这个 module path 为“example.com/foo/bar”的模块)需要依赖一个 module path 为“apple”的模块,并且通过“replace”指令告诉了 go 这个模块的位置在当前项目的上一级目录的一个叫做“apple”的目录下。通过类似这样的做法,就可以解决你的那个问题了。

感谢你的耐心回答。我发现了问题的错误点在于项目文件内有不正当的import path,导致go mod tidy会报这样的错误,但这不影响项目的编译。

@liesauer
Copy link

@aofei 貌似还真是GO111MODULE 问题,我昨天编译了一个master分支的go,并覆盖了之前的1.12,按道理新版的都是默认开启的,强制GO111MODULE="on"解决了

@liesauer
Copy link

但是唯独有一个包装不上,不知道啥问题

gocode-gomod:
Error: Command failed: /Users/imac/Projects/go/bin/go build -o /Users/imac/go/bin/gocode-gomod github.com/stamblerre/gocode
can't load package: cannot find module providing package github.com/stamblerre/gocode: working directory is not part of a module
can't load package: cannot find module providing package github.com/stamblerre/gocode: working directory is not part of a module

@maxwellhertz
Copy link

@liesauer

这个是明显的 Go module proxy 没有在工作呢,而且似乎是连 Go modules 都没有被启用。

是不是设置错了 GOPROXY 环境变量?或者 GO111MODULE 环境变量没有设置为 on?或者你的 IDE 覆盖了这两个环境变量的其中一个?目前我知道的是有些 IDE 比如 GoLand 会覆盖着两个环境变量,还有就是 vim-go 会选择性地调整 GO111MODULE

您好,请问 Goland 覆盖 proxy 环境变量的问题要怎么解决呢?

@aofei
Copy link
Member

aofei commented Oct 28, 2019

你好,@maxwellhertz

GoLand 在项目设置中应该叫“Go Modules (vgo)”的选项,把里面的“Proxy”设置为https://goproxy.cn就好了,如果你是 Go 1.13 的话就设置成https://goproxy.cn,direct

详见:https://www.jetbrains.com/help/go/create-a-project-with-vgo-integration.html

@maxwellhertz
Copy link

你好,@maxwellhertz

GoLand 在项目设置中应该叫“Go Modules (vgo)”的选项,把里面的“Proxy”设置为https://goproxy.cn就好了,如果你是 Go 1.13 的话就设置成https://goproxy.cn,direct

详见:https://www.jetbrains.com/help/go/create-a-project-with-vgo-integration.html

谢谢,已解决!

@aofei
Copy link
Member

aofei commented Nov 6, 2019

似乎当前这个 Issue 中的所有问题都已经得到了解决,所以我就先关闭这个 Issue 了,如果还有其他问题欢迎随时提问,我会尽快响应的,谢谢大家啦~😊

@zhang14725804
Copy link

私有仓库 module lookup disabled by GOPROXY=off : packages.Load error。。这是什么问题呢 @ @aofei @liesauer @yjbdsky @preminem @maxwellhertz

@aofei
Copy link
Member

aofei commented Aug 23, 2021

@zhang14725804

你好,这种问题多半是你的 GOPROXY 环境变量配置有误,请保证它是 https://goproxy.cn,direct,注意尾部的 ,direct 很重要。如果你改完后还是无效,麻烦贴出完整的 go env 结果便于排查。

另外,这是一个已经关闭很久的 issue 了,下次有问题的话开新的 issue 会好一点。❤️

@zhang14725804
Copy link

@zhang14725804

你好,这种问题多半是你的 GOPROXY 环境变量配置有误,请保证它是 https://goproxy.cn,direct,注意尾部的 ,direct 很重要。如果你改完后还是无效,麻烦贴出完整的 go env 结果便于排查。

另外,这是一个已经关闭很久的 issue 了,下次有问题的话开新的 issue 会好一点。❤️

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/zxh178/Library/Caches/go-build"
GOENV="/Users/zxh178/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/zxh178/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/zxh178/go"
GOPRIVATE=""
GOPROXY="https://goproxy.cn,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/zxh178/Desktop/temporary/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/8q/zyxhpgnn3fvc7gx2g1s_cclc0000gp/T/go-build102393732=/tmp/go-build -gno-record-gcc-switches -fno-common"

@aofei
Copy link
Member

aofei commented Aug 23, 2021

@zhang14725804

这个配置虽然不完美但其实可行,通过 404 可以 fallback 到你的目标私有库。完美的配置应该是将你们内部的源加入到 GOPRIVATE 环境变量中,比如 GOPRIVATE=git1.internal.example.com,git2.internal.example.com

此外,需要提一点,如果你贴出来的这个配置是你系统终端中获取的结果,那么要注意如果你用了比如 GoLand 之类的 IDE 的话,它们通常会覆盖系统环境变量,也就是说你可能需要再在 IDE 中单独配置一下这些相关环境变量。

@zhang14725804
Copy link

@zhang14725804

这个配置虽然不完美但其实可行,通过 404 可以 fallback 到你的目标私有库。完美的配置应该是将你们内部的源加入到 GOPRIVATE 环境变量中,比如 GOPRIVATE=git1.internal.example.com,git2.internal.example.com

此外,需要提一点,如果你贴出来的这个配置是你系统终端中获取的结果,那么要注意如果你用了比如 GoLand 之类的 IDE 的话,它们通常会覆盖系统环境变量,也就是说你可能需要再在 IDE 中单独配置一下这些相关环境变量。

好的好的,谢谢你,太感谢了

@hdw868
Copy link

hdw868 commented Nov 5, 2021

goproxy是不是一定要配合gomodule11=on使用?

@aofei
Copy link
Member

aofei commented Nov 5, 2021

@hdw868

GO111MODULE 是控制 go 命令是否应该把当前项目视为 Go modules 项目的开关环境变量,所以它必须能被显式地或隐式地(也就是 auto,让 go 自己去抉择)解释为 on 才行。

另外自从 Go 1.16 起,GO111MODULE 已经被默认为 on 了,而且未来它将被彻底移出,也就是说永久性地为 on

@zhaoshuai202
Copy link

你好,你把 go env -w GO111MODULE=on 这条命了也执行一遍试试看。

@hdw868

GO111MODULE 是控制 go 命令是否应该把当前项目视为 Go modules 项目的开关环境变量,所以它必须能被显式地或隐式地(也就是 auto,让 go 自己去抉择)解释为 on 才行。

另外自从 Go 1.16 起,GO111MODULE 已经被默认为 on 了,而且未来它将被彻底移出,也就是说永久性地为 on

我下载的go1.16,没有使用这个命令go env -w GO111MODULE=on 之前会遇到无法下载的问题如下:
go: github.com/fatih/[email protected]: Get "https://proxy.golang.org/github.com/fatih/color/@v/v1.10.0.mod": dial tcp 172.217.160.113:443: i/o timeout
使用了这条命令后就可以了。
这是不是说默认行为还是false,另外,为什么这个标志打开,就可以下载了?

@aofei
Copy link
Member

aofei commented Dec 15, 2021

这是不是说默认行为还是false

不是,从 Go 1.16 开始 GO111MODULE 就已经默认为 on 了,这里的“默认”指的是当用户并没有显式地设置过 GO111MODULE 时(即其为空时)默认为 on。你之所以需要再显式地设置一次,就说明在这之前你的 GO111MODULE 已经有了值。

为什么这个标志打开,就可以下载了?

GO111MODULE 是控制 go 命令是否应该把当前项目视为 Go modules 项目的开关环境变量,所以 off 时你的当前项目还是属于 GOPATH 模式的。

@zhaoshuai202
Copy link

你好,你把 go env -w GO111MODULE=on 这条命了也执行一遍试试看。

设置了这个还是失败,可以这样'go env -w GO111MODULE=on && go env -w GOPROXY=https://goproxy.cn,direct '

@aofei
Copy link
Member

aofei commented Dec 15, 2021

@zhaoshuai202

也许你还有系统级环境变量设置,它们比 go env -w 所设置的优先级要高。你可以通过 export GO111MODULE=on 以及 export GOPROXY=https://goproxy.cn,direct 来修改这些系统级的环境变量。

@Hanvans
Copy link

Hanvans commented Aug 27, 2022

o: honnef.co/go/[email protected]: Get "https://goproxy.cn/honnef.co/go/tools/@v/v0.0.0-20190102054323-c2f93a96b099.info": Internal Privoxy Error

What should I do in this situation?

@aofei
Copy link
Member

aofei commented Aug 27, 2022

@Hanvans

“Internal Privoxy Error”

这个错误指的是你环境中的其他系统级代理出了问题,跟 goproxy.cn 是无关的,因为压根儿就还没连接到 goproxy.cn。

@liwan14x
Copy link

liwan14x commented Jul 5, 2023

gotests: failed to install gotests(github.com/cweill/gotests/[email protected]): Error: Command failed: C:\Program Files\Go\bin\go.exe install -v github.com/cweill/gotests/[email protected]
go: github.com/cweill/gotests/[email protected]: github.com/cweill/gotests/[email protected]: Get "https://goproxy.cn/github.com/cweill/gotests/gotests/@v/v1.6.0.info": dial tcp 146.112.61.106:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

set GO111MODULE=on
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\liwan14x\AppData\Local\go-build
set GOENV=C:\Users\liwan14x\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\liwan14x\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\liwan14x\go
set GOPRIVATE=
set GOPROXY=https://goproxy.cn,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=off
set GOTMPDIR=
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.20.5
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=NUL
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=C:\Users\liwan14x\AppData\Local\Temp\go-build2745368859=/tmp/go-build -gno-record-gcc-switches

我尝试了网上的各种方法,并且确定我可以用公司的内网访问goproxy.cn 但是我始终无法下载工具,请问谁知道这是什么原因吗?非常期待并感谢您的回复

@aofei
Copy link
Member

aofei commented Jul 5, 2023

dial tcp 146.112.61.106:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

类似的错误说明你的机器上还配置了比如 HTTP_PROXYHTTPS_PROXY 这种系统范围的其他通用代理,这导致 Go 语言的默认 HTTP client 自动读取并使用了它们,也就是说你的 go 命令原本应该是直连 goproxy.cn 但此时却因为这些个错误配置的其他通用代理导致了并非直连。

解决办法,建议检查你机器上的其他代理软件并纠正它们的错误配置。

@liwan14x
Copy link

liwan14x commented Jul 5, 2023

C:\Users\liwan14x>set http_proxy
Environment variable http_proxy not defined

C:\Users\liwan14x>set https_proxy
Environment variable https_proxy not defined

我检查了一下全局变量里没有设置代理,setting->proxy 中 代理关掉或者打开各种方式都试过了还是不行。。。其他地方没有下载代理软件,公司内网必须设置代理才可访问外部网站,所以我一直开着Automatically detect settings

@liwan14x
Copy link

liwan14x commented Jul 5, 2023

dial tcp 146.112.61.106:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

类似的错误说明你的机器上还配置了比如 HTTP_PROXYHTTPS_PROXY 这种系统范围的其他通用代理,这导致 Go 语言的默认 HTTP client 自动读取并使用了它们,也就是说你的 go 命令原本应该是直连 goproxy.cn 但此时却因为这些个错误配置的其他通用代理导致了并非直连。

解决办法,建议检查你机器上的其他代理软件并纠正它们的错误配置。

谢谢 确实是公司这破网的问题,我连手机热点拉了一些必须的包下来,后面我再找找原因

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants