1. set launch.json
        {
            "name": "Attach",
            "type": "go",
            "request": "launch",
            "mode": "remote",
            "remotePath": "${workspaceRoot}",
            "port": 2345,
            "host": "127.0.0.1",
            "program": "${workspaceRoot}",
            "env": {},
            "args": [],
            "showLog": true
        }
  1. go build && run
  2. get pid && dlv attach $pid  --headless=true --api-version=2--listen=:2345 --log
  3. in VSCode, Click begin debug button

* 注意go build要带上这个标记 -gcflags='-N -l',目的是关闭Go内部做的一些优化,聚合变量和函数内联等优化。

* 或者直接这样运行dlv --listen=:2345 --headless=true --api-version=2 exec ./demo

相关文章:

  • 2021-09-09
  • 2021-05-20
  • 2022-12-23
  • 2021-11-26
  • 2021-10-17
  • 2021-10-22
  • 2021-09-09
猜你喜欢
  • 2022-12-23
  • 2022-01-13
  • 2021-06-24
  • 2022-12-23
  • 2022-12-23
  • 2021-04-24
  • 2021-08-26
相关资源
相似解决方案