提问人:moluzhui 提问时间:11/17/2023 最后编辑:moluzhui 更新时间:11/17/2023 访问量:90
如何使用 go get 命令从公司的 gitlab 仓库下载私有项目
How to use the go get command to download private projects from the company's gitlab repository
问:
我有一个项目需要依赖内部 gitlab 私有库。
我通过以下命令配置了它,但发生了 URL 404 错误。示例如下
$ go env -w GOPRIVATE=a.b.com
$ go env -w GOINSECURE=a.b.com
$ go get -v -x a.b.com/testgroup/compkg
# get https://a.b.com/?go-get=1
# get https://a.b.com/testgroup/testpkg?go-get=1
# get https://a.b.com/testgroup?go-get=1
# get https://a.b.com/testgroup?go-get=1: 404 Not Found (0.044s)
# get https://a.b.com/?go-get=1: 403 Forbidden (0.044s)
# get https://a.b.com/testgroup/testpkg?go-get=1: 404 Not Found (0.044s)
# get https://a.b.com/testgroup/testpkg?go-get=1
# get https://a.b.com/testgroup?go-get=1
# get https://a.b.com/?go-get=1
# get https://a.b.com/testgroup/testpkg?go-get=1: 404 Not Found (0.001s)
# get https://a.b.com/testgroup?go-get=1: 404 Not Found (0.001s)
# get https://a.b.com/?go-get=1: 403 Forbidden (0.002s)
go get: unrecognized import path "a.b.com/testgroup/testpkg": reading https://a.b.com/testgroup/testpkg?go-get=1: 404 Not Found
然后我试着切换到ssh来拉,例子如下
$ git config --global url."[email protected]:testgroup/compkg.git".insteadOf "https://a.b.com/testgroup/compkg"
$ go get -v -x a.b.com/testgroup/compkg
# get https://a.b.com/?go-get=1
# get https://a.b.com/testgroup/testpkg?go-get=1
# get https://a.b.com/testgroup?go-get=1
# get https://a.b.com/testgroup?go-get=1: 404 Not Found (0.044s)
# get https://a.b.com/?go-get=1: 403 Forbidden (0.044s)
# get https://a.b.com/testgroup/testpkg?go-get=1: 404 Not Found (0.044s)
# get https://a.b.com/testgroup/testpkg?go-get=1
# get https://a.b.com/testgroup?go-get=1
# get https://a.b.com/?go-get=1
# get https://a.b.com/testgroup/testpkg?go-get=1: 404 Not Found (0.001s)
# get https://a.b.com/testgroup?go-get=1: 404 Not Found (0.001s)
# get https://a.b.com/?go-get=1: 403 Forbidden (0.002s)
go get: unrecognized import path "a.b.com/testgroup/testpkg": reading https://a.b.com/testgroup/testpkg?go-get=1: 404 Not Found
两次尝试都出现相同的错误。go get: unrecognize import path “a.b.com/testgroup/compkg”: reading https://a.b.com/testgroup/compkg?go-get=1
: 404 未找到
我使用以下 curl 命令返回以下错误:
$ curl --insecure https://a.b.com/testgroup/compkg?go-get=1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>
<head><title>404 Not Found</title></head>
<body bgcolor="white">
<h1>404 Not Found</h1>
<p>The requested URL was not found on this server.<hr/>Powered by Tengine</body>
</html
有没有其他方法可以尝试,或者是我的试错?期待您的回复。
PS:a.b.com/test/compkg 没有任何 git 标签,并且是 groupname 不是 gitlab 的用户名。
testgroup
- gitlab 版本:Gitlab 社区版 13.6.7
- Go 版本:Go v1.16
- 我可以通过输入用户名和密码进行投影
git pull
答: 暂无答案
评论
reading https://
go get
git pull
go get
git pull
go get