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

调试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?

  • 写回答

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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 使用C#,asp.net读取Excel文件并保存到Oracle数据库
  • ¥15 C# datagridview 单元格显示进度及值
  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配