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

Support revision (version/tag) for Godoc handler for Sourcegraph redirection link #17547

Closed

Conversation

joshuabezaleel
Copy link

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%2Flogrus@v0.7.0&source=pkgsite
redirected to Go's package handler
https://sourcegraph.com/go/github.com/sirupsen/logrus@v0.7.0/hooks/syslog/-/SyslogHook/Fire
and the finally redirected to the respective file content at
http://sourcegraph.com/github.com/sirupsen/logrus@v0.7.0/-/blob/hooks/syslog/syslog.go#L25:25&tab=references

Short demo can be seen below. We can see that:

  1. It also supports method and submodule of the particular package.
  2. Method SyslogHook's Fire is at line 25 at the version v0.7.0 while it's located at line 28 at the latest/default version (v1.3.0) of the logrus package.
sourcegraph-gddo.mp4

Alternatives
I am using the path/to/repo@v1.2.3 style to append the version to the particular repo since this is how I found the Sourcegraph(sourcegraph.com/github.com/sirupsen/logrus@v0.7.0/-/blob/hooks/syslog/syslog.go#L25:25&tab=references) and pkg.go.dev(pkg.go.dev/github.com/sirupsen/logrus@v1.3.0) 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&repo=REPO@v1.3.0&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 🙂

@joshuabezaleel
Copy link
Author

Hi @sqs !
I am really sorry for a very late response and PR to this issue since I felt really under the weather for the past few weeks that I missed this issue and just got reminded because of the Golang's team announcement 🙁 .
Hope that this could still be useful and thank you lots for the help over the Twitter DM earlier. Looking forward to the review 😃 .

@keegancsmith
Copy link
Member

beep-boop I am a bearded bot. This PR has not been updated for more than 6 months so I am closing it. Please re-open if I this is still active.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support revision (version/tag) query params on Godoc handler for Sourcegraph usage redirection link
2 participants