This repository has been archived by the owner on Sep 30, 2024. It is now read-only.
Support revision (version/tag) for Godoc handler for Sourcegraph redirection link #17547
+22
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes: #15557
What and why
This PR will support adding revision (version/tag) for the incoming request handler from Godoc's golang package, which will be used to further add the Sourcegraph link redirection to the new Golang package documentation site pkg.go.dev replacing .org. I think this will be beneficial since all of the requests to the Godoc will all be redirected to pkg.go.dev in the near future (announcement).
The issue, PR, and short demo for the Sourcegraph redirection on pkg.go.dev can be found on the respective link.
How
This will enable adding the revision (version/tag) for the URL constructed on the pkg.go.dev site compared to the one constructed at godoc.org. The expected one will works like this, starting at the godoc handler:
https://sourcegraph.com/-/godoc/refs?def=SyslogHook%2FFire&pkg=github.com%2Fsirupsen%2Flogrus%2Fhooks%2Fsyslog&repo=github.com%2Fsirupsen%[email protected]&source=pkgsite
redirected to Go's package handler
https://sourcegraph.com/go/github.com/sirupsen/[email protected]/hooks/syslog/-/SyslogHook/Fire
and the finally redirected to the respective file content at
http://sourcegraph.com/github.com/sirupsen/[email protected]/-/blob/hooks/syslog/syslog.go#L25:25&tab=references
Short demo can be seen below. We can see that:
sourcegraph-gddo.mp4
Alternatives
I am using the
path/to/[email protected]
style to append the version to the particular repo since this is how I found the Sourcegraph(sourcegraph.com/github.com/sirupsen/[email protected]/-/blob/hooks/syslog/syslog.go#L25:25&tab=references) and pkg.go.dev(pkg.go.dev/github.com/sirupsen/[email protected]) implement it.I am open to input whether it's better to just use another query param for the link (become
sourcegraph.com/-/godoc/refs?def=DEF&pkg=PKG&repo=REPO&ver=1.3.0&source=pkgsite
instead of
sourcegraph.com/-/godoc/refs?def=DEF&pkg=PKG&[email protected]&source=pkgsite)
Additional context
I don't add much since almost all of mechanics are already handled by the current codebase and also @sqs gave me really helpful pointers on the changes that needs to be done. Thank you so much 🙂