vscode-go icon indicating copy to clipboard operation
vscode-go copied to clipboard

mode debug can't set binary path

Open Lioncky opened this issue 7 months ago • 2 comments

launch.sjon

        {
            "name": "XDLMSrv-Debug",
            "type": "go",
            "request": "launch",
            "mode": "debug",
            "program": ".", // main.go
            "buildFlags": "-o .vs/debug.exe", // if set this path, the debugger won't launch
            "env": { "_DEBUG": "true"}
        },

if not set, the windows firewall will always show the information of allow or deny the debugger program

Lioncky avatar May 04 '25 20:05 Lioncky

Are you seeing any error messages when trying to launch the debugger?

If you haven't seen it already, here's our documentation about launch configurations for debugging: https://github.com/golang/vscode-go/blob/master/docs/debugging.md
Specific launch.json attributes are listed here: https://github.com/golang/vscode-go/blob/master/docs/debugging.md#launchjson-attributes

madelinekalil avatar May 05 '25 21:05 madelinekalil

❓ Problem Summary:

When using "mode": "debug" in your launch.json for Go in VSCode, the debugger (Delve) compiles a temporary executable like debug_bin_xxxx.exe every time. On Windows:

  • This file changes name every time (due to randomness).
  • Windows Firewall prompts you each time for permission.
  • Specifying buildFlags does not control the output binary name.
  • It's annoying and can block debugging.

Lioncky avatar May 05 '25 22:05 Lioncky