douhe3313
2018-04-09 12:28
浏览 393
已采纳

调试Golang代码并将其附加到本地进程

Im having a Golang code which I create from it binary for mac via go build like:

build darwin amd64 myapp

Currently Im able to run the binary and see the logs.

Now I want to debug it , is there a way to debug the binary with Goland or Intellij or VSCode ? regular debug with delve is working from all the IDE's above but now I want to attach it to the binary process which I was able to run,Any idea if it possible?

图片转代码服务由CSDN问答提供 功能建议

我有一个Golang代码,该代码是我通过go build从Mac二进制文件中创建的 like: \ n

build darwin amd64 myapp

当前我能够运行二进制文件并查看日志。

现在我要调试它,是否有一种方法可以使用 Goland Intellij VSCode 调试二进制文件 ? 使用 delve 进行的常规调试在上述所有IDE中都可以正常工作,但现在我想将其附加到我能够运行的二进制进程中,如果可以的话,知道吗?

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • doutu2017 2018-04-09 13:24
    已采纳

    If you use GoLand 2018.1+ you should be able to use the Run | Attach to Local Process feature and it will allow you to debug a running binary.

    I suggest that you compile the binary with all the optimizations turned off and compiled with Go 1.10+ in order to get the best debugging experience.

    Furthermore, the IDE can launch the binary and debug it in a single click, removing the need to perform multiple steps.

    One last issue that I can mention is that you currently will not be able to correctly debug Go apps via Delve, so regardless of which editor you use, due to a bug introduced by Apple in the latest developer tools. For more information please see the issue on our tracker: https://youtrack.jetbrains.com/issue/GO-5527 and on Delve's tracker: https://github.com/derekparker/delve/issues/1165

    Edit:

    The issue mentioned above was resolved in GoLand 2018.1.1.

    已采纳该答案
    打赏 评论

相关推荐 更多相似问题