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

Open
erbesharat opened this issue Sep 21, 2019 · 5 comments

Comments

@erbesharat
Copy link

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

This comment has been minimized.

Copy link

commented Sep 21, 2019

shouldn't it be more like:

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

This comment has been minimized.

Copy link
Author

commented Sep 22, 2019

@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

This comment has been minimized.

Copy link

commented Sep 22, 2019

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

This comment has been minimized.

Copy link
Author

commented Sep 22, 2019

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

@bcmills

This comment has been minimized.

Copy link
Member

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 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.