How to use the go get command to download private projects from the company's gitlab repository

117 views Asked by At

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

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 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."[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

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

I used the following curl command to return the following error:

$ 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

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

PS: a.b.com/test/compkg does not have any git tag And testgroup is groupname not username of gitlab.

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

There are 0 answers