简体   繁体   English

vscode Golang调试launch.json配置

[英]vscode Golang debugging launch.json configuration

Trying to use vscode debugger to debug my go code.尝试使用 vscode 调试器调试我的 go 代码。
vscode runs all the.go files in the same dir using the following launch.json config file: vscode 使用以下 launch.json 配置文件在同一目录中运行所有 .go 文件:

        {
            "name": "Test",
            "type": "go",
            "request": "launch",
            "mode": "test",
            "program": "${relativeFileDirname}",
        }     

Obviously, I tried to change "program": "${relativeFileDirname}", -> "program": "${file}", but it's not working.显然,我试图更改"program": "${relativeFileDirname}", -> "program": "${file}",但它不起作用。
In addition, is there a way I can run ut and not the whole file (or in this case the whole dir)?此外,有没有一种方法可以运行 ut 而不是整个文件(或者在本例中是整个目录)?

You can use the following launch.json configuration to run the main.go file in the same directory as.vscode.您可以使用以下 launch.json 配置在与.vscode 相同的目录中运行 main.go 文件。 Change the file name main.go to the corresponding go file to run them将文件名main.go改为对应的go文件即可运行

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "some name",
            "type": "go",
            "request": "launch",
            "mode": "auto",
            "program": "main.go",
        }
    ]
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM