douchaqi3369 2018-06-19 04:14
浏览 21
已采纳

远程调试Go REST端点

I am new to Go and new to VSCode. I have also never used Delve before. I am trying to set up remote debugging but i can't seem to hit breakpoints.

My project hosts REST endpoints on localhost:8080. What should the launch.json file look like in order to have delve attach and listen so that I can put breakpoints on my REST endpoints? Currently, this is what i have:

"configurations": [
    {
        "name": "Launch",
        "type": "go",
        "request": "launch",
        "mode": "remote",
        "remotePath": "",
        "port": 8080,
        "host": "127.0.0.1",
        "program": "${workspaceRoot}",
        "env": {},
        "args": [],
        "showLog": true
    }

Thanks in advance!

  • 写回答

1条回答 默认 最新

  • doujingya1166 2018-06-19 04:53
    关注

    This article mentioned:

    Unfortunately, you won’t be able to debug an application when running with buffalo dev. You’ll need to build an executable that skips compiler optimizations like function invocation inlining.
    If you skip these build flags Gogland won’t stop on your break points.

    More on that on "Debugging Go Code with GDB ".

    The code generated by the gc compiler includes inlining of function invocations and registerization of variables. These optimizations can sometimes make debugging with gdb harder.

    After that, you can follow "Remote Debugging"

    To remote debug using VS Code, you must first run a headless Delve server on the target machine. For example:

    $ dlv debug --headless --listen=:2345 --log
    

    Then your launcher can apply.

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

报告相同问题?

悬赏问题

  • ¥15 如何实现H5在QQ平台上的二次分享卡片效果?
  • ¥15 python爬取bilibili校园招聘网站
  • ¥30 求解达问题(有红包)
  • ¥15 请解包一个pak文件
  • ¥15 不同系统编译兼容问题
  • ¥100 三相直流充电模块对数字电源芯片在物理上它必须具备哪些功能和性能?
  • ¥30 数字电源对DSP芯片的具体要求
  • ¥20 antv g6 折线边如何变为钝角
  • ¥30 如何在Matlab或Python中 设置饼图的高度
  • ¥15 nginx中的CORS策略应该如何配置