Giter VIP home page Giter VIP logo

Comments (8)

aofei avatar aofei commented on June 1, 2024 1

所以是不是使用自建 goproxy 的话,都推荐在本地设置 GOSUMDBGONOSUMDB

公共代理,比如使用 goproxy.cn,本地建议保留 GOSUMDB 为其默认值 sum.golang.org(因为官方可信),另外配置 GOPRIVATE 来针对私有模块绕过 GOPROXYGOSUMDB,或者分开单独配置 GONOPROXY/GONOSUMDBGOPRIVATE 只是它俩的默认值而已。

私有代理,也就是使用通过 Goproxy 自建的,本地建议 GOSUMDB=off,因为模块数据校验行为应在私有代理所处的服务端完成。

公共代理、私有代理混合存在,也就是你的场景,就像前面说的建议的是在本地配置只配置 GONOSUMDB

from goproxy.

aofei avatar aofei commented on June 1, 2024

你好,请问上述错误信息是服务端 Goproxy 进程所打印的,还是你在本地执行 go get 命令时所打印的?如果是本地所打印的,请提供下你本地环境的 go env 输出。

from goproxy.

elricli avatar elricli commented on June 1, 2024

本地执行报错,

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.

aofei avatar aofei commented on June 1, 2024

嗯,这就是问题所在了。

注意看,你的 GOPROXY 环境变量是一个逗号列表,逗号列表的意思是“如果前一个代理返回了 404/410 响应,那就自动 fallback 到下一个代理“,所以在你的本地网络与 goproxy.cn 之间不存在任何障碍时,go get 使用的是 goproxy.cn。又因为你的 GOSUMDB 是默认的 sum.golang.org,所以在你本地的 GONOSUMDB 未正确配置时,go get 会使用 goproxy.cn 进行模块校验操作。

目前针对你的情况的解决办法,是将你们的私有模块 host 配置进本地的 GONOSUMDB

from goproxy.

elricli avatar elricli commented on June 1, 2024

那这样的话,是不是有两种解决方案:

  1. 把内部 goproxy 地址移至 goproxy.cn
  2. 把内部 gitlab 地址添加至 GONOSUMDB

from goproxy.

aofei avatar aofei commented on June 1, 2024

方案 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.

elricli avatar elricli commented on June 1, 2024

了解了,感谢。

所以是不是使用自建 goproxy 的话,都推荐在本地设置 GOSUMDBGONOSUMDB

from goproxy.

elricli avatar elricli commented on June 1, 2024

好的,谢谢谢谢~

from goproxy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.