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

x/pkgsite: suggest canonical module/package path when visiting repository path #43518

Closed
danp opened this issue Jan 5, 2021 · 4 comments
Closed

Comments

@danp
Copy link
Contributor

@danp danp commented Jan 5, 2021

I was recently browsing https://github.com/rsc/rf and wanted to see its godoc so I naively visited https://pkg.go.dev/github.com/rsc/rf. This presented me with the Oops! We couldn't find “github.com/rsc/rf”. page which confused me.

Then I realized it may have a different canonical module path, so I checked go.mod and indeed it's at rsc.io/rf. Visiting https://pkg.go.dev/rsc.io/rf then worked as expected.

It would be nice if pkgsite suggested visiting https://pkg.go.dev/rsc.io/rf to me when visiting https://pkg.go.dev/github.com/rsc/rf. It seems to already know that rsc.io/rf comes from github.com/rsc/rf as part of linking github.com/rsc/rf under "Repository" at https://pkg.go.dev/rsc.io/rf.

This would also align with what happens when trying to go get github.com/rsc/rf in an existing module, which does suggest the canonical path:

% go get github.com/rsc/rf 
go: downloading github.com/rsc/rf v0.0.0-20210102024717-be19e66fb52d
go: github.com/rsc/rf upgrade => v0.0.0-20210102024717-be19e66fb52d
go get: github.com/rsc/rf@v0.0.0-20210102024717-be19e66fb52d: parsing go.mod:
	module declares its path as: rsc.io/rf
	        but was required as: github.com/rsc/rf
@gopherbot gopherbot added the pkgsite label Jan 5, 2021
@gopherbot gopherbot added this to the Unreleased milestone Jan 5, 2021
@mvdan
Copy link
Member

@mvdan mvdan commented Jan 5, 2021

As someone who uses vanity import paths, this would be welcome. Too many users still default to assuming they can use the github URL as-is, as either an import path or for the docs. That should fail and it already does, but the pkgsite failure is confusing with the 404.

@jba jba modified the milestones: Unreleased, pkgsite/unplanned Jan 5, 2021
@julieqiu
Copy link
Contributor

@julieqiu julieqiu commented Jan 6, 2021

If you visit https://pkg.go.dev/github.com/rsc/rf and click on the Request github.com/rsc/rf button, it'll show this message:

image

We're working on a change soon to redirect users to the appropriate vanity import path.

@gopherbot
Copy link

@gopherbot gopherbot commented Jan 6, 2021

Change https://golang.org/cl/281872 mentions this issue: internal/frontend: redirect alternative module paths

@gopherbot
Copy link

@gopherbot gopherbot commented Jan 6, 2021

Change https://golang.org/cl/281678 mentions this issue: content,internal/frontend: add redirect banner for alternative module paths

gopherbot pushed a commit to golang/pkgsite that referenced this issue Jan 6, 2021
When a fetch request reports that a path is an alternative module path,
redirect the user to the canonical path.

For golang/go#43518

Change-Id: I0835a46e8f104ed6c404fa8184578487af55cc54
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/281872
Trust: Julie Qiu <julie@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants