vscode-go
vscode-go copied to clipboard
Add an action to copy a link to a file in the online repository for a module dependency
Is your feature request related to a problem? Please describe. I would like to share reference to lines of code in public repository of imported packages when discussing issues with my teammates.
Describe the solution you'd like
It would be nice to have an action item in the context menu under Copy As > Copy link to remote repository
Describe alternatives you've considered
Additional context
Hi YesYouKenSpace,
I find a tool offered from GitLens. I'm not sure if this is something you are looking for. If you configured correctly, you will find options below.
But this is limited to understanding your repo allow you to customize the repo url with file, line and range parameter. It does not understand the library you imported in your repo unless you vendor them (make those as part of your repo). But standard lib is always out of reach because it can not be vendored.
I think what they mean is: If I open a file from the module cache (for example by using "Go to definition" on an imported type), I want a "Copy link to file" menu option that links to the online repository for that package. I don't think GitLens can solve this because the module cache files aren't git repositories.
@YesYouKenSpace If I'm correct this would be tricky to handle in the general case. Obviously if the module starts with github.com it's not that hard to determine a browsable URL for that file. However supporting other providers would require a go-get query for each module and that only works if the provider includes a go-source meta tag.
Timed out in state WaitingForInfo. Closing.
(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)
@firelizzard18 yeap you are right that is what i meant. I think even if supporting just the common code hosting sites is good enough for most open source projects. Already makes it easier to reference open source libraries.
@h9jiang thank you for pointing out gitlens. I do have gitlens too and i was unable to refer to the lib that are imported.
@YesYouKenSpace Can you clarify when you want this option to appear? I can think of multiple scenarios. I had been thinking when you right click the file tab after opening a file from the module cache as in [right click method/etc] -> [go to definition] -> [right click file tab] -> [copy link] but from your screenshot it looks like you want this option to appear when right clicking a definition, as in [right click method/etc] -> [copy link] as an alternative to [go to definition].
@firelizzard18 i expect it to be available at a right click on any line within a file of the module cache. I believe that to be the most intuitive.
I imagine myself navigating in the team codebase and then travelling to the public library definition and finding a piece of code in the module cache that explains a behaviour and wanting to link my teammates to that line.
That's sufficiently clear. The request is:
- As a user, when I open a file within the module cache, I want a context menu option to copy a link to the online repository for that file.
- For example, if I open
~/go/pkg/mod/github.com/spf13/[email protected]/command.go(e.g. by Go to Definition) and I right click, I want a context menu option that will placehttps://github.com/spf13/cobra/blob/v1.8.1/command.goon the clipboard, ideally with#LXXfor the line number I right clicked on.
As far as implementation, it should be relatively straightforward for github, gitlab, and other well-known providers. Supporting arbitrary providers (e.g. custom GitLab deployments such as https://gitlab.freedesktop.org/) will require checking for a go-source meta tag with a go-get query as I mentioned before https://github.com/golang/vscode-go/issues/3656#issuecomment-2581077483.
Thank you good sir @firelizzard18, ah yes i probably should have just started with a user story.