在 Visual Studio 代码 WSL 中调试 Go 代码

Debugging Go code in Visual Studio Code WSL

我有一个 Visual Studio 代码环境,带有 windows 运行 的 Linux 子系统,它正在编译 运行 一个 Go 项目就好了。

现在我正尝试在 link:

之后获取 delve 调试器 运行

https://github.com/Microsoft/vscode-go/wiki/Debugging-Go-code-using-VS-Code

但是我无法获取运行,无论是远程还是本地。

尝试了 launch.json 中的所有配置,但断点未命中且未打印任何错误消息。

有人使用 WSL 在 VSCode 上调试 运行 吗?

旧 post,但无法深入研究 WSL

https://github.com/go-delve/delve/issues/1235

有更好的资源可以完整解释为什么它不起作用,现在找不到

显然这与 WSL 没有完全实现 Linux 有关...但它会在 WSL2 中实现!

https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux

如果可以切换到WSL2,microsoft/vscode-go issue 2505确认:

Since WSL2 is working with this, I think we can close the bug

WSL2 will be generally available in Windows 10, version 2004.
Windows 10 version 2004 is "20H1",因为是2020年上半年上映