当前位置: 首页 > 工具软件 > goenv > 使用案例 >

go get执行无法下载包,报warning: go env -w GOPROXY=... does not override conflicting OS environm

范华清
2023-12-01

打开cmd,执行go env

C:\Users\86131>go env
set GO111MODULE=on
set GOARCH=amd64
set GOBIN=D:\study\Go\GoProject\bin
set GOCACHE=C:\Users\86131\AppData\Local\go-build
set GOENV=C:\Users\86131\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=D:\study\Go\GoProject\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=D:\study\Go\GoProject
set GOPRIVATE=
set GOPROXY=https://goproxy.cn,direct
set GOROOT=D:\study\Go\GOROOT\go1.17.3
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=D:\study\Go\GOROOT\go1.17.3\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.17.3
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=NUL
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=C:\Users\86131\AppData\Local\Temp\go-build1098379897=/tmp/go-build -gno-record-gcc-switches

打开goland命令行,执行go env

D:\study\Go\GoProject\src\gin_demo>go env
set GO111MODULE=on
set GOARCH=amd64
set GOBIN=D:\study\Go\GoProject\bin
set GOCACHE=C:\Users\86131\AppData\Local\go-build
set GOENV=C:\Users\86131\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=D:\study\Go\GoProject\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=D:\study\Go\GoProject
set GOPRIVATE=
set GOPROXY=https://goproxy.cn
set GOROOT=D:\study\Go\GOROOT\go1.17.3
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=D:\study\Go\GOROOT\go1.17.3\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.17.3
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=D:\study\Go\GoProject\src\gin_demo\go.mod
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=C:\Users\86131\AppData\Local\Temp\go-build3744853949=/tmp/go-build -gno-record-gcc-switches

经过对比:两个输出的GOPROXY的值不同

  • 一个是 set GOPROXY=https://goproxy.cn,direct
  • 另一个是 set GOPROXY=https://goproxy.cn

在其中一个配置set GOPROXY=https://goproxy.cn,direct 或者 set GOPROXY=https://goproxy.cn,配置成与另一个相同即可。

 类似资料: