远程 dlv 调试缓慢问题
2024-08-13
- 在双方机器安装调试工具
go install github.com/go-delve/delve/cmd/dlv@latest
- 配置环境变量:
export PATH=$PATH:$GOPATH/bin
- 在远程机器启动对应服务:
dlv --listen :33333 --api-version=2 --headless --accept-multiclient --allow-non-terminal-interactive exec {program-to-run} -- {program-args}
- 在 vscode 中进行类似配置进行远程调试:
{ "version": "0.2.0", "configurations": [ { "name": "remote-debug", "type": "go", "request": "attach", "mode": "remote", "host": "{address-to-remote-server}", "port": 33333, # 加入适配器配置,否则可能导致调试极其缓慢的问题 # 参见:https://github.com/golang/vscode-go/releases/tag/v0.41.3 "debugAdapter": "dlv-dap", # 源代码路径映射 "substitutePath": [ { # 本地路径 "from":"${workspaceFolder}", # 远程路径 "to":"{remote-source-folder}, } ] } ] }