模块查找被 GOPROXY=off 禁用,但是 go env 显示 GOPROXY 已设置。

huangapple go评论106阅读模式
英文:

module lookup disabled by GOPROXY=off, but go env shows GOPROXY is set

问题

在尝试查找一些模块时,我在VS Code中遇到了一个问题。下面的错误提示表明我的GOPROXY被设置为off,但是当我运行go env时,我看到GOPROXY实际上被设置为:GOPROXY="https://repo1.mycompany.com/artifactory/api/go/golang-virtual,https://proxy.golang.org,direct"

我尝试设置GONOPROXY='',如这个评论所建议的,但是在运行export GONOPROXY=export GONOPROXY=""之后,并在新的终端选项卡中检查go env,GONOPROXY仍然被设置为:GONOPROXY="*.mycompany.com"

按照VS Code的建议运行go mod tidy会得到相同的错误消息。

是否可能我的go env值被设置在我不知道的地方,也许是Go的其他版本的环境变量?提前感谢任何帮助,非常感谢。

VS Code的错误截图:
模块查找被 GOPROXY=off 禁用,但是 go env 显示 GOPROXY 已设置。

英文:

When trying to lookup some modules, I am having an issue from VS Code where the error pictured below indicates that my GOPROXY is set to off, but when I run go env, I see that GOPROXY is actually set:GOPROXY="https://repo1.mycompany.com/artifactory/api/go/golang-virtual,https://proxy.golang.org,direct"

I have tried setting GONOPROXY='', as this comment suggests, but after running export GONOPROXY= or export GONOPROXY="", and checking go env in a new terminal tab, GONOPROXY is still set to: GONOPROXY="*.mycompany.com"

Running go mod tidy as VS Code suggests, results in the same error message.

Is it possible that my go env values are being set somewhere that I don't know about, maybe a different version of Go's env vars? Thanks in advance, any help is greatly appreciated.

VS Code's error screenshot:
模块查找被 GOPROXY=off 禁用,但是 go env 显示 GOPROXY 已设置。

答案1

得分: 31

只需按下Ctrl + Shift + P,然后选择"开发者: 重新加载窗口"。

模块查找被 GOPROXY=off 禁用,但是 go env 显示 GOPROXY 已设置。

英文:

Simply Ctrl + Shift + P > Developer: Reload window

模块查找被 GOPROXY=off 禁用,但是 go env 显示 GOPROXY 已设置。

答案2

得分: 1

最新的文档已更新了GOPROXY标志proxy.golang.org,其中说明:

> 要选择退出此模块镜像,您可以通过设置GOPROXY=direct来关闭它。

因此,要绕过代理并直接从go.mod中的URL获取:

export GOPROXY=direct

go clean --modcache
go get -u
go build
英文:

The latest docs have updated the GOPROXY flag proxy.golang.org, which states:

> To opt-out of this module mirror, you can turn it off by setting GOPROXY=direct

So to bypass the proxy and fetch directly from the URLs in go.mod:

export GOPROXY=direct

go clean --modcache
go get -u
go build

huangapple
  • 本文由 发表于 2022年2月8日 01:53:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/71023129.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定