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

Open
garethwarry opened this Issue Mar 29, 2017 · 3 comments

Comments

Projects
None yet
3 participants
@garethwarry

garethwarry commented Mar 29, 2017

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

This comment has been minimized.

Member

bradfitz commented Mar 29, 2017

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 from URL Redirection in "Go Get" Command to cmd/go: support URL Redirection in "go get" from custom to known import path? Mar 29, 2017

@garethwarry

This comment has been minimized.

garethwarry commented Mar 29, 2017

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.

@garethwarry

This comment has been minimized.

garethwarry 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment