duanlu5055 2018-08-07 17:47
浏览 139

GoLang调试控制台应用程序

I am trying to debug this project

I am using visual studio code, and have the Go extension setup. I am able to set a breakpoint in the main function and debug it, but I never see the visual command prompt. I used Delve, ran the exe that the project produces, and attached. This allowed me to debug it, but I would prefer to debug it in vscode.

I tried using this vscode debug configuration:

    {
        "name": "Launch file",
        "type": "go",
        "request": "attach",
        "mode": "exec",
        "program": "${workspaceFolder}/lazygit.exe"
    },

and it is successful. But again, I cannot see the actual command window and actually use the project.

Is there any way to attach to an already open process in vscode, like in delve, or for vscode to launch the exe in a command window?

  • 写回答

1条回答 默认 最新

  • dongyan5815 2018-08-07 17:53
    关注

    You are using the .exe file for debugging the code. Use the raw code to denug the application. Also there is a debug console where you can see the output when debugging using breakpoints or in case of any error. The configurations for launch.json should be:

    {
        "name": "Launch",
        "type": "go",
        "request": "launch",
        "mode": "debug",
        "remotePath": "",
        "port": 2345,
        "host": "127.0.0.1",
        "program": "${workspaceFolder}",
        "env": {},
        "args": [],
        "showLog": true
    }
    

    Debug console will show the output of debugging and stdout:

    enter image description here

    评论

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?