visual studio – I can’t catch a breakpoint in VS Code when debugging an app in Go (golang)


I wrote an api server in go, set a breakpoint, and then started debugging in the VS Code IDE

[Starting the server and debugging mode]

At the first launch, the breakpoint is triggered, then my server starts using the go: log.Fatal(http.ListenAndServe(“:8080”, nil))

[after I missed the first server launch, I expect that the breakpoint will work after a request to my server via postman]

After that I send a GET request via postman to my server at http://127.0.0.1:8080/avatars/, I expected the breakpoint to work, however. the server executed the request and returned a response, bypassing the breakpoint

go env:

Breakpoints worked for me earlier, according to the scheme described above, a few months later I returned to the Go code again, but the breakpoints no longer worked as before, I searched the entire Internet in search of a solution to my problem, however, everyone stops at the first start of the debugging process when the DAP server starts, but I I did not see how to call a breakpoint in subsequent times of execution of this code, for example, by sending requests via Postman, I changed the settings in VS Code launch.json, for example debugAdapter on “legacy”, setting exactly the same address for listening by the debugger, to which I send requests from Postman, but the result is zero, I tried to change mode to exec and other options, but it didn’t help, I tried to build the application by creating an executable file.exe, in order to then join this process, however, to no avail, I tried to reinstall the Go extension in VS Code, but the breakpoint seemed invisible to the IDE, after launching the application while sending requests to the server, I also tried another option to create the server itself with another project. I use the delve debugger, according to the instructions I added it to my development environment before debugging. I will be glad to receive any advice on which direction I should move in order to solve this problem, thank you in advance.

Leave a Reply

Your email address will not be published. Required fields are marked *