我是靠谱客的博主 迷路小霸王,这篇文章主要介绍VSCode远程调试Go程序方法(Attach),现在分享给大家,希望可以做个参考。

  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

转载于:https://www.cnblogs.com/mrblue/p/9069084.html

最后

以上就是迷路小霸王最近收集整理的关于VSCode远程调试Go程序方法(Attach)的全部内容,更多相关VSCode远程调试Go程序方法(Attach)内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(137)

评论列表共有 0 条评论

立即
投稿
返回
顶部