英文:
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的其他版本的环境变量?提前感谢任何帮助,非常感谢。
英文:
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.
答案1
得分: 31
只需按下Ctrl + Shift + P
,然后选择"开发者: 重新加载窗口"。
答案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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论