Eden Berdugo
Eden Berdugo

Reputation: 339

vscode Golang debugging launch.json configuration

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)?

Upvotes: 4

Views: 14324

Answers (2)

freemanpolys
freemanpolys

Reputation: 1998

This one works too :

{
"version": "0.2.0",
"configurations": [

    {
        "name": "Launch Package",
        "type": "go",
        "request": "launch",
        "mode": "auto",
        "program": "${workspaceRoot}"
    }
]

}

Upvotes: 0

sajir mohamed
sajir mohamed

Reputation: 535

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",
        }
    ]
}

Upvotes: 11

Related Questions