关于golang1.13版本国内代理无法使用问题

编程入门 行业动态 更新时间:2024-10-12 22:27:40

关于golang1.13<a href=https://www.elefans.com/category/jswz/34/1771446.html style=版本国内代理无法使用问题"/>

关于golang1.13版本国内代理无法使用问题

 

         golang1.13发布后 我们go get 一些资源的时候就不用通过特殊方式来下载了,官方提供了代理资源,

但是按照操作一波下来后发现出现以下问题:

go get -u github/mdempsky/gocode
package golang/x/tools/go/gcexportdata: unrecognized import path "golang/x/tools/go/gcexportdata" (https fetch: Get =1: dial tcp 216.239.37.1: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.)

go get -u github/mdempsky/gocode
package golang/x/tools/go/gcexportdata: unrecognized import path "golang/x/tools/go/gcexportdata" (https fetch: Get =1: dial tcp 216.239.37.1: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.)

看上去并无法访问到资源,

官方指出 通过这种方式去设置:

go env -w GOPROXY=direct
go env -w GOSUMDB=off

设置后并没有效果,其实仔细看下文档

The GOPROXY environment variable may now be set to a comma-separated list of proxy URLs or the special token direct, and its default value is now ,direct. When resolving a package path to its containing module, the go command will try all candidate module paths on each proxy in the list in succession. An unreachable proxy or HTTP status code other than 404 or 410 terminates the search without consulting the remaining proxies.

说是需要 ,direct 这个地址 

那么我们改成这样:

go env -w GOPROXY=,direct

再次去go get 资源 还是无法代理加载

这个时候我们 go env 看下是否设置好

 

go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=***
set GOENV=*************
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GONOPROXY=*.corp.example
set GONOSUMDB=*.corp.example
set GOOS=windows
set GOPATH=************
set GOPRIVATE=*.corp.example
set GOPROXY=,direct
set GOROOT=*******
set GOSUMDB=off
set GOTMPDIR=
set GOTOOLDIR=*******
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=********

 

GOPROXY 其实已经是我们设置的代理了(*号根据自己目录请勿参考),

然后我们发现 第一个 GO111MODULE 是空的 那么问题找到了

我们只需要打开它

go env -w GO111MODULE="on"

然后再去加载资源

go get -u github/mdempsky/gocode
go: finding github/mdempsky/gocode latest
go: downloading github/mdempsky/gocode v0.0.0-20190203001940-7fb65232883f
go: extracting github/mdempsky/gocode v0.0.0-20190203001940-7fb65232883f
go: finding golang/x/tools latest
go: downloading golang/x/tools v0.0.0-20190911022129-16c5e0f7d110
go: extracting golang/x/tools v0.0.0-20190911022129-16c5e0f7d110

已经代理成功!!!!!!!

    希望可以帮到大家,如有问题多多指教!!! 

更多推荐

关于golang1.13版本国内代理无法使用问题

本文发布于:2024-02-27 07:28:22,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1705703.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:版本   国内

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!