Coder Social home page Coder Social logo

Comments (9)

aofei avatar aofei commented on May 29, 2024
  • 配置 .netrc
  • 配置 ssh key + git config url."[email protected]".insteadOf "git.private.com"

这两种方案均可。

注意默认情况下 go get 所发出的是 HTTPS 请求,此时你需要在 Goproxy 进程所属用户的 Home 目录下放置 .netrc 文件。如果 Home 目录下已经放置了 SSH 密钥,那大可采用第二种方案了。

from goproxy.

elricli avatar elricli commented on May 29, 2024

感谢

from goproxy.

elricli avatar elricli commented on May 29, 2024

@aofei 哈喽大佬,我这里 goproxy 现在遇到一个问题,访问 http://goproxy.example.com/gitlab.private.com/dev/redigo/@v/list,报 404 Not Found。公司其他私有包(go.mod 中的 module 写的是公司 GitLab 地址)是正常的。

dev/redigo 项目来自 fork GitHub 上的 gomodule/redigo,并 dev/redigo 中的 go.mod 并没有变动。

使用 dev/redigo 的方式:replace github.com/gomodule/redigo => gitlab.private.com/dev/redigo v1.8.4

goproxy 使用的是 netrc,另外该账户也是有权限的,即git ls-remote -q 是有输出 tag 信息。

综上所述,是我遗漏了哪些步骤吗?

from goproxy.

aofei avatar aofei commented on May 29, 2024

你的 .netrc 文件是在 Goproxy 进程所属环境用户的 Home 目录下吗?如果是的话,你可以试试相同环境下 go list -m -versions -json gitlab.private.com/dev/redigo@latest 是否可以正常返回结果。

另外,据我所知 GitLab 之前的版本存在有 Bug,所有 subgroup 级别的 repo 都不支持 ?go-get=1 查询,因此 go get 等命令也就不能使用,你们 GitLab 的版本是多少?

from goproxy.

elricli avatar elricli commented on May 29, 2024

GitLab 版本:14.5.0
goproxy 部署方式: docker,用户 root

go list -m -versions -json gitlab.private.com/dev/redigo@latest

goproxy 所属机器没配 GOPRIVATE 的环境变量,所以执行 go list 不能正常返回结果,但是另外加上 GOPRIVATE=xxx go list 就可以返回。

我这边启动 goproxy 进程是通过 GoBinEnv 配置 GOPRIVATE=xx
代码:

srv := &http.Server{
	Addr: cfg.ServerAddr,
	Handler: &server{
		Goproxy: &goproxy.Goproxy{
			// cfg.Environments 这里配置了 GOPROXY=xxx 、GOPRIVATE=xxx 、GOSUMDB=xxx
			GoBinEnv:            append(os.Environ(), cfg.Environments...),
			ProxiedSUMDBs:       cfg.ProxiedSUMDBs,
			Cacher:              cacher,
			CacherMaxCacheBytes: cfg.Cacher.MaxSize,
		},
	},
}

from goproxy.

aofei avatar aofei commented on May 29, 2024

GitLab 的版本不存在任何问题,很新。

但是另外加上 GOPRIVATE=xxx go list 就可以返回。

指的是你在 Docker 容器内部执行 go list 时可以正常返回对吧?需要注意 .netrc 应该在 Docker 容器内部的 /root/.netrc,并非宿主机的。不过这点你应该也知道,顺便说一下以防万一。

我这边启动 goproxy 进程是通过 GoBinEnv 配置 GOPRIVATE=xx

倒也不用把环境变量写进代码里,设置进程的环境变量即可。

总之,如果你手动执行 go list 是可以正常返回结果的,那么 Goproxy 的进程也应该可以正常获取才对。

from goproxy.

elricli avatar elricli commented on May 29, 2024

倒也不用把环境变量写进代码里,设置进程的环境变量即可。

有一个点很奇怪,即:gitlab.private.com/dev/pkg2,这个包是可以获取到的,即 goproxy.example.com/gitlab.private.com/dev/pkg2/@v/list 是有输出的。

from goproxy.

aofei avatar aofei commented on May 29, 2024

你的 GOPRIVATE 是怎么设置的?你需要设置成 GOPRIVATE=gitlab.private.com

from goproxy.

elricli avatar elricli commented on May 29, 2024

结案了。

module path 和 module version 是存在 escape 机制的,大写字母需要 escape,比如 Dev 要被 escape 成 !dev。

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.