Go get download private project of private gitlab failed

I have a project that needs to rely on the private project of private gitlab.

I configured it through the following command, but a URL 404 error occurred. The example is as follows

$ go env -w GOPRIVATE=a.b.com
$ go env -w GOINSECURE=a.b.com
$ go env -w GONOPROXY=a.b.com
$ git config --global url."https://username:private-token@a.b.com".insteadOf "http://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

Then I tried to switch to ssh to pull, the example is as follows

$ git config --global url."git@a.b.com: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

Same error on both attempts. go get: unrecognize import path "a.b.com/testgroup/compkg": reading https://a.b.com/testgroup/compkg?go-get=1: 404 Not Found

Is there any other way to try, or is it my trial and error? Looking forward to your reply.

PS: testgroup is groupname not username of gitlab.

  • gitlab version: Gitlab Community Edition 13.6.7
  • go version: go v1.16 and v1.20
  • I can git clone project by enter username and password

Your GOPRIVATE env looks correct to me. I’ve used that before with private modules and it worked OK but I’m not super experienced with private modules or anything. Maybe follow this guide?

Unfortunately, I tried following the link and changed the address to mine, but the error is still there.

I don’t know if it is because I use the gitlab group rather than the user name. gitlab.company.com/group/reponame instead of gitlab.company.com/myusername/reponame

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.