我有一个文件夹 D:\Data\Git\go\src\demo 包含一个文件 main.go。 我已经安装了go1.12.6 windows/amd64。 (我正在运行 Windows 10) 我无法调试应用程序 - 调试器在屏幕上闪烁然后消失 ==> 没有任何反应 ==> 即使我设置了断点,它也不会中断交互式单步执行的代码! 我可以从命令行运行应用程序 ==> go run main.go(当前目录是 main.go 所在的位置)
我的 launch.json 看起来像这样:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}",
"env": {},
"args": []
}
]
}
这是我的应用:
package main
import "fmt"
func main() {
s := []int{2, 3, 5, 7, 11, 13}
s = s[1:4]
fmt.Println(s)
}
如何在 VS Code 中进行调试?
最佳答案
这里是答案:
Ctrl+Shift+P ==> 打开 Launch.json ==> 保存 ==> 瞧!
(有效。我现在可以在 Visual Studio Code 中使用一个 main.go 文件单步执行和调试一个简单的应用程序)
请注意,我已经安装了所有开发工具(按照上面的@owlwalks),以及 dlv(参见此处:https://github.com/Microsoft/vscode-go/wiki/Debugging-Go-code-using-VS-Code)
关于go - 无法在 visual studio 代码中调试 Go,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56820192/