Go 远程调试

Goland Go Remote (Goland 远程调试)

安装 Delve

首先确保云服务器上安装了 Delve 调试器:

go install github.com/go-delve/delve/cmd/dlv@latest

云服务器上运行程序

dlv exec –listen=:2345 –headless=true –api-version=2 –accept-multiclient –continue ./demo.exe

最佳实践建议:

  • dlv 使用 –continue 参数,启动时不阻塞等待dlv客户端连接,直接运行服务端程序
  • 断开连接时选择保持运行。调试结束后,程序不会关闭,就不需要再次开启服务器
  • 确保本地代码和远端代码一致

滚动至顶部