vscode golang 调试时如何生成固定的名字,而不是__debug_bin3821025376.exe 这种随机名字? 如果是 win 系统 程序带网络监听功能的话每次调试都需要允许防火墙操作。
![]() |
1
guanzhangzhang 12 天前 ![]() github 搜索__debug_bin https://github.com/search?q=repo%3Ago-delve%2Fdelve%20__debug_bin&type=code
走到这个逻辑 debugname = gobuild.DefaultDebugBinaryPath("__debug_bin") 而 DefaultDebugBinaryPath 函数逻辑是 CreateTemp func DefaultDebugBinaryPath(name string) string { pattern := name if runtime.GOOS == "windows" { pattern += "*.exe" } f, err := os.CreateTemp(".", pattern) |
![]() |
2
guanzhangzhang 12 天前 ![]() 只有设置 output 才是固定的,没设置就是上面逻辑
|
3
FEINIAO233 12 天前 ![]() 设置.vscode 目录下的 launch.json ,output 参数可以固定,类似
{ "version": "0.2.0", "configurations": [ { "name": "调试主程序", "type": "go", "request": "launch", "mode": "auto", "program": "${workspaceFolder}/main.go", "env": {}, "args": [], "cwd": "${workspaceFolder}", "output": "${workspaceFolder}/output/debug_app" } ] } |
![]() |
4
xdeng OP |
![]() |
5
xdeng OP 忘了去看 dlv 的源码了
|