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: support URL Redirection in "go get" from custom to known import path? #19760

Closed
spiritedsnowcat opened this issue Mar 29, 2017 · 4 comments
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@spiritedsnowcat
Copy link

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

go version go1.8 windows/amd64

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

set GOARCH=amd64
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows

What did you do?

Attempted to use a redirected URL in "go get" command, tested using a temporary redirect (301) or permanent redirect (302). "Go get" command fails with an error "did not match import path". The redirected destination in the "go get" command works. Attempted manual commands using git commands:

git init
git remote add origin https://garethwarry@warry.io/test.git
touch README.md
echo placeholder>README.md
git add README.md
git commit -m "placeholder"
git push -u origin master

Git worked with redirection (so confirmed it wasn't git).

What did you expect to see?

Redirected URL works. For example: "warry.io" redirects to "github.com/garethwarry". I can call "go get warry.io/test" rather than "go get github.com/garethwarry/test".

What did you see instead?

G:>go get -d -v warry.io/test
Fetching https://warry.io/test?go-get=1
Parsing meta tags from https://warry.io/test?go-get=1 (status code 200)
package warry.io/test: unrecognized import path "warry.io/test" (parse https://warry.io/test?go-get=1: no go-import meta tags (meta tag github.com/garethwarry/test did not match import path warry.io/test))

@bradfitz
Copy link
Contributor

We did follow the redirect, and then fetched https://github.com/garethwarry/test?go-get=1 which didn't have go-import meta tags.

You want to be able to redirect from a custom import path to a known import path (like github) and then have us recognize that pattern?

That seems too convoluted to be worth both testing and documenting the precedence rules.

If you control warry.io, why don't you just serve the expected (and documented) format? (especially at least when Go says "?go-get=1").

@bradfitz bradfitz changed the title URL Redirection in "Go Get" Command cmd/go: support URL Redirection in "go get" from custom to known import path? Mar 29, 2017
@bradfitz bradfitz added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Mar 29, 2017
@spiritedsnowcat
Copy link
Author

Well, it seems that by following the redirect, the go get command does get the meta tags for the known import path. The problem is that it then checks that known path against the custom import path and actively rejects it. It would be nice if that could be ignored by a flag or something. I'm not exactly sure of the purpose of that check to begin with.

@spiritedsnowcat
Copy link
Author

spiritedsnowcat commented Mar 30, 2017

Interesting update, if I do "go get warry.io/test.git", that works.
It creates an odd/undesired directory structure though of "$GOPATH/src/warry.io/test.git/".
Found from here: gitlabhq/gitlabhq#5958

@ianlancetaylor ianlancetaylor added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Apr 13, 2018
@ianlancetaylor ianlancetaylor added this to the Unplanned milestone Apr 13, 2018
@ALTree ALTree removed the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Jan 7, 2020
@seankhliao
Copy link
Member

i think the design of go modules requires strict module identity. retrieving through alternate locations can be done with replace.

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Jan 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

5 participants