英文:
vscode Golang debugging launch.json configuration
问题
尝试使用VSCode调试器来调试我的Go代码。
VSCode使用以下launch.json配置文件来运行同一目录中的所有.go文件:
{
"name": "Test",
"type": "go",
"request": "launch",
"mode": "test",
"program": "${relativeFileDirname}",
}
显然,我尝试将
"program": "${relativeFileDirname}",
改为 "program": "${file}",
但它不起作用。
此外,有没有办法只运行单元测试而不是整个文件(或在这种情况下是整个目录)?
英文:
Trying to use vscode debugger to debug my go code.
vscode runs all the .go files in the same dir using the following launch.json config file:
{
"name": "Test",
"type": "go",
"request": "launch",
"mode": "test",
"program": "${relativeFileDirname}",
}
Obviously, I tried to change
"program": "${relativeFileDirname}",
-> "program": "${file}",
but it's not working.
In addition, is there a way I can run ut and not the whole file (or in this case the whole dir)?
答案1
得分: 3
你可以使用以下的launch.json配置来运行与.vscode文件夹中的main.go文件相同目录下的文件。将文件名main.go更改为要运行的相应go文件。
{
"version": "0.2.0",
"configurations": [
{
"name": "某个名称",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "main.go",
}
]
}
英文:
You can use the following launch.json configuration to run the main.go file in the same directory as .vscode. Change the file name main.go to the corresponding go file to run them
{
"version": "0.2.0",
"configurations": [
{
"name": "some name",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "main.go",
}
]
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论