Support `revision` (version/tag) query params on Godoc handler for Sourcegraph usage redirection link
Created by: joshuabezaleel
Feature request description
I am currently working on this particular PR for this issue to implement Sourcegraph usage redirection link for pkg.go.dev like the way it currently is in godoc.org (short demo can be seen here).
Jonathan Amsterdam, one of the maintainers reminded me that pkg.go.dev supports revision/version for a particular Go package that was not implemented in godoc.org which means that this revision
also needs to be implemented for the Sourcegraph usage redirection link for pkg.go.dev.
Is your feature request related to a problem? If so, please describe.
The current Godoc handler does not support revision/version/tag yet for a particular Go package.
Describe alternatives you've considered.
The current Sourcegraph usage redirection handler for sirupsen/logrus's Printf will use this link from the godoc.org
https://sourcegraph.com/-/godoc/refs?def=Printf&pkg=github.com%2Fsirupsen%2Flogrus&repo=github.com%2Fsirupsen%2Flogrus&source=pkgsite
which will redirect to
http://sourcegraph.com/go/github.com/sirupsen/logrus/-/Printf
and then ended up on
https://sourcegraph.com/github.com/sirupsen/logrus/-/blob/exported.go#L193:6&tab=references
.
The PR for this issue will support revision on the repo
query param which means for a revision @v1.3.0
the link from the pkg.go.dev will yield
https://sourcegraph.com/-/godoc/refs?def=Printf&pkg=github.com%2Fsirupsen%2Flogrus&repo=github.com%2Fsirupsen%[email protected]&source=pkgsite
for the serveGDDORefs
handler which will then redirect to
http://sourcegraph.com/go/github.com/sirupsen/[email protected]/-/Printf
for the serveGoSymbolURL
handler and then ended up on
https://sourcegraph.com/github.com/sirupsen/[email protected]/-/blob/exported.go#L142:6&tab=references
.
This is needed since the same Printf
function are on different location/line for different revision/version (line 193 in the latest version and line 142 in the @v1.3.0
version).
Additional context
@sqs kindly answered my questions for the Sourcegraph usage redirection link that I am currently working on and gave me really helpful pointers! Thank you so much!