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 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置