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: trouble using go-import's mod vcs with a custom import path #34445

Closed
erbesharat opened this issue Sep 21, 2019 · 6 comments
Closed

cmd/go: trouble using go-import's mod vcs with a custom import path #34445

erbesharat opened this issue Sep 21, 2019 · 6 comments
Labels
FrozenDueToAge modules WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@erbesharat
Copy link

erbesharat commented Sep 21, 2019

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

$ go version
go version devel +ecc7dd5469 Sat Sep 21 16:31:44 2019 +0000 linux/amd64

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/erbesharat/.cache/go-build"
GOENV="/home/erbesharat/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/erbesharat/workspace"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/erbesharat/.test/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-build190480021=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I used this go-import tag in response to go get so I can use my custom proxy server to fetch the package and use it by the vanity URL, not the real package's import path.

<meta name="go-import" content="github.com/myreal/package mod https://example.test/modproxy">

What did you expect to see?

I expected to receive the mod requests (list, etc.) from go get on https://example.test/modproxy.

What did you see instead?

The mod meta tag gets skipped and go get uses the git vcs tag. Because the import path is not the same as the meta tag's prefix, it goes into this condition:
https://github.com/golang/go/blob/master/src/cmd/go/internal/get/vcs.go#L985

@seankhliao
Copy link
Member

seankhliao commented Sep 21, 2019

shouldn't it be more like:

<meta name="go-import" content="vanity.tld/module mod https://example.test/modproxy">

@erbesharat
Copy link
Author

@seankhliao No, it doesn't work like that. It's because x should be a prefix of the given import path to go get.

<meta name="go-import" content="x mod y">

@seankhliao
Copy link
Member

But afaik GitHub urls receive special treatment (making ?go-get=1) unnecessary, so if you want to change the import behavior you need a vanity url

@erbesharat
Copy link
Author

I've tested it with a GitHub url too and in all cases, it goes to the mentioned condition.

@bcmills
Copy link
Contributor

bcmills commented Sep 23, 2019

@erbesharat, only the server at github.com gets to serve go-import paths for github.com (see https://golang.org/cmd/go/#hdr-Remote_import_paths).

Do you have a concrete example of this problem using your own server on a domain that you control?

@bcmills bcmills added modules WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Sep 23, 2019
@bcmills bcmills changed the title Vanity URLs support for go-import's mod vcs cmd/go: trouble using go-import's mod vcs with a custom import path Sep 23, 2019
@gopherbot
Copy link

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

@golang golang locked and limited conversation to collaborators Oct 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge modules WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants