How to debug a Golang program in VS Code using delve?

92 Views Asked by At

I am trying to debug my code using delve. My code builds. But when I start a debug session, delve cannot build it.

I am using VS Code. I click on the run and debug button on the left. Then the button to the left of launch pad on the lop. I get compiler errors:

./myprogram.go:118:32: too many errors (exit status 1).

This is my launch.json file:

"version": "0.2.0",
"configurations": [
    {
        "name": "Launch Package",
        "type": "go",
        "request": "launch",
        "mode": "auto",
        "program": "myprogram.go"
    }
]

Do you know what the problem is?

I read the delve tutorials, but I could not find anything which addresses the issue.

I chose Delve because it was written by the Golang team.

Any suggestions for another debugger?

1

There are 1 best solutions below

5
Kaustubh Parmar On

Are you sure your code builds? Maybe the file that is built is different from the one in the launch.json file ie. "myprogram.go". Can you confirm that this is the file?