Comments (8)
所以是不是使用自建 goproxy 的话,都推荐在本地设置
GOSUMDB
或GONOSUMDB
?
公共代理,比如使用 goproxy.cn,本地建议保留 GOSUMDB
为其默认值 sum.golang.org
(因为官方可信),另外配置 GOPRIVATE
来针对私有模块绕过 GOPROXY
和 GOSUMDB
,或者分开单独配置 GONOPROXY
/GONOSUMDB
,GOPRIVATE
只是它俩的默认值而已。
私有代理,也就是使用通过 Goproxy 自建的,本地建议 GOSUMDB=off
,因为模块数据校验行为应在私有代理所处的服务端完成。
公共代理、私有代理混合存在,也就是你的场景,就像前面说的建议的是在本地配置只配置 GONOSUMDB
。
from goproxy.
你好,请问上述错误信息是服务端 Goproxy 进程所打印的,还是你在本地执行 go get
命令时所打印的?如果是本地所打印的,请提供下你本地环境的 go env
输出。
from goproxy.
本地执行报错,
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/mikado/.cache/go-build"
GOENV="/home/mikado/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/mikado/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/mikado/go"
GOPRIVATE=""
GOPROXY="https://goproxy.cn,http://goproxy.private.com,direct"
GOROOT="/usr/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.17.8"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="0"
GOMOD="/home/mikado/GoLabs/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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1973494546=/tmp/go-build -gno-record-gcc-switches"
补充:本地执行 GOSUMDB=off go get
是能正常拉取的
from goproxy.
嗯,这就是问题所在了。
注意看,你的 GOPROXY
环境变量是一个逗号列表,逗号列表的意思是“如果前一个代理返回了 404/410 响应,那就自动 fallback 到下一个代理“,所以在你的本地网络与 goproxy.cn 之间不存在任何障碍时,go get
使用的是 goproxy.cn。又因为你的 GOSUMDB
是默认的 sum.golang.org
,所以在你本地的 GONOSUMDB
未正确配置时,go get
会使用 goproxy.cn 进行模块校验操作。
目前针对你的情况的解决办法,是将你们的私有模块 host 配置进本地的 GONOSUMDB
。
from goproxy.
那这样的话,是不是有两种解决方案:
- 把内部 goproxy 地址移至
goproxy.cn
前 - 把内部 gitlab 地址添加至
GONOSUMDB
中
from goproxy.
方案 1 还存在另外一个问题,就是你的 Goproxy 代码中还配置了个 ProxiedSUMDBs: "sum.golang.org https://goproxy.cn/sumdb/sum.golang.org"
,这依然会导致你本地 go get
试图通过 sum.golang.org
去校验模块版本,这里需要注意你 Goproxy 所处环境的 GOPRIVATE
并不在这一步骤参与工作。
事实上,针对只是用私有代理的情况,建议是 GOSUMDB=off
,因为所有的校验行为都应放在 Goproxy 所处的服务端去完成,这样所有本地客户端经过私有代理所获取到的模块版本都是 100% 可信任的,本地的模块校验反倒成了多余。
from goproxy.
了解了,感谢。
所以是不是使用自建 goproxy 的话,都推荐在本地设置 GOSUMDB
或 GONOSUMDB
?
from goproxy.
好的,谢谢谢谢~
from goproxy.
Related Issues (20)
- GOPROXY变量中的direct的作用是什么 HOT 2
- Cache HOT 10
- Unable to complete go get command when GOPROXY=direct HOT 11
- /tmp required but not configurable HOT 3
- 可以使用 goproxy 解决私有 GitLab 仓库问题吗? HOT 9
- goproxy 无法代理私有 GitLab多级子目录问题 HOT 4
- 请求某个资源时容易出现500错误 HOT 2
- failed to list module versions HOT 5
- 代理有时会产生http2: server sent GOAWAY and closed the connection错误 HOT 3
- 无法拉取gitlab中的私有包 HOT 18
- goproxy responds with HTTP/1.0 on response to CONNECT, some clients do not support this HOT 1
- Disable-Module-Fetch: true header support HOT 1
- server panic HOT 2
- is there a changelog? HOT 1
- goproxy redirect http proxy to transparent proxy cause some http quest 400 error HOT 1
- support /@latest endpoint HOT 4
- [BUG] go get stuck and server output git error HOT 6
- 拉取私有仓库问题 HOT 2
- 502了 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from goproxy.