How to view external go module dependencies in vscode

huangapple go评论68阅读模式
英文:

How to view external go module dependencies in vscode

问题

有时候我真的需要浏览并检查添加到我的Go模块的外部依赖的代码。

虽然我可以通过CMD+点击方法来打开来自外部依赖的Go文件,但我真的很想看到并快速检查包中的其他文件。

Goland可以通过显示模块依赖来实现这一点。

有没有办法在Visual Studio Code中启用显示模块依赖?

英文:

Sometimes I really need to browse and check the code from external dependencies add to my go module.

Although I could CMD+click on the method and vscode editor opens the go file from external dependency, I would really like to see and quickly check other files from the package.

Goland allows this by showing module dependencies.

Is there any way to enable displaying module dependencies in visual studio code?

答案1

得分: 3

我不确定这种方法是否像你想要的那样快速,但是在你使用 cmd+Click 并打开外部文件后,你可以选择以下任一方式:

  1. 通过导航栏浏览整个文件,这样你可以查看依赖项的版本,并在模块目录中选择不同的版本。
  2. 或者你可以复制路径 [Ctrl+K Ctrl+Alt+C 在 Linux 上],然后打开终端并执行 code <文件目录>。这将在一个新的 vscode 窗口中打开该目录,以便你可以查看所有外部依赖项的文件。

我知道这看起来像是很多步骤,但一旦你习惯了 vscode 的快捷方式(复制路径、打开终端),我认为这是目前最好的方法 How to view external go module dependencies in vscode

英文:

I'm not sure if this way is as quickly as you want, but after you cmd+Click and reached the external file you can do either of

  1. Navigate all the file through navbar, this way you can check what version of the dependency and you can choose between different version that is available on your module directorey How to view external go module dependencies in vscode

2. Or you can Copy Path [Ctrl+K Ctrl+Alt+C on linux] then open terminal and do code &lt;file-directory&gt;. It opens a new vscode window on that directory so you can check all the files of the external dependencies.

I know it seems like a lot of step but once you get used to vscode shortcut(copy path, open terminal) i think it's the best we have right now How to view external go module dependencies in vscode

答案2

得分: 2

在官方的VS Code的Go扩展中没有这样的功能,也没有其他提供这个功能的扩展。

然而,在Go扩展中有一个未解决的问题https://github.com/golang/vscode-go/issues/2156。它没有太多的投票(在我看来),但它被分配到一个里程碑,其中包含了至少在讨论中的想法。

希望这能帮到你。

英文:

There is no such feature in the oficial Go extension for VS Code, or any extension that provides that as well.

However, there is an open issue https://github.com/golang/vscode-go/issues/2156 in the Go extension. It does not have too many votes (IMO), but it is assigned to a milestone that holds ideas that at least, are on the table to discussion.

Hope this helps

huangapple
  • 本文由 发表于 2022年3月18日 14:29:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/71523201.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定