Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: "package?go-get=1 404 not found" errors occurs when go get private project in internal private gitlab repository #64223

Closed
learneryork opened this issue Nov 17, 2023 · 2 comments

Comments

@learneryork
Copy link

learneryork commented Nov 17, 2023

What version of Go are you using (go version)?

$ go version
go v1.16

Does this issue reproduce with the latest release?

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN="/usr/local/go/bin"
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE="a.b.com"
GOMODCACHE="/root/go/pkg/mod"
GONOPROXY="https://a.b.com"
GONOSUMDB=""
GOOS="linux"
GOPATH="/root/go"
GOPRIVATE="https://a.b.com"
GOPROXY="https://goproxy.io,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.google.cn"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.16.12"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/test/workspace/demo/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 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3882968519=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Modify the configuration to be able to download private projects from private gitlab repositories

Approach 1

$ go env -w GOPRIVATE=a.b.com
$ go env -w GOINSECURE=a.b.com
$ go get a.b.com/testgroup/compkg

Approach 2

$ git config --global url."git@a.b.com:testgroup/compkg.git".insteadOf "https://a.b.com/testgroup/compkg"
$ go get a.b.com/testgroup/compkg

Approach 3

$ vim ~/.netrc
machine a.b.com
              username abcd
              password  private-token

PS: testgroup is groupname not username in gitlab

What did you expect to see?

I can download private project successfullly and use it import

What did you see instead?

go get failed, the error is as follows

$ go get -v -x a.b.com/testgroup/testpkg
# 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

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

$ curl --insecure https://a.b.com/testgroup/compkg?go-get=1
...
404 Not Found
...
@seankhliao
Copy link
Member

we don't support 1.16 anymore.

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For questions please refer to https://github.com/golang/go/wiki/Questions

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Nov 17, 2023
@shaneHowearth
Copy link

shaneHowearth commented Nov 24, 2023

For the record I've been having a very similar problem with go get
(I am considering filing an issue, but I am appending this here in case anyone finds this helpful)

go version
go version go1.21.4 linux/arm64

The issue was "fixed" by changing the go.mod of the project I have hosted privately to be

module shanehowearth.com/my/project.git
...

and

go get shanehowearth.com/my/project.git

Note: The Proxy info still needs to be set

No amount of .gitconfig fu would get go get to fetch the repository that is hosted on my on servers

See: https://stackoverflow.com/questions/60645866/how-can-i-make-go-get-work-with-a-repo-on-a-local-server for more information

I consider it an issue because there seems to be no /logical/ reason that go get should require the module to be named *.git in order for ssh to be used to fetch it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants