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

    评论

报告相同问题?

悬赏问题

  • ¥15 彩灯控制电路,会的加我QQ1482956179
  • ¥200 相机拍直接转存到电脑上 立拍立穿无线局域网传
  • ¥15 (关键词-电路设计)
  • ¥15 如何解决MIPS计算是否溢出
  • ¥15 vue中我代理了iframe,iframe却走的是路由,没有显示该显示的网站,这个该如何处理
  • ¥15 操作系统相关算法中while();的含义
  • ¥15 CNVcaller安装后无法找到文件
  • ¥15 visual studio2022中文乱码无法解决
  • ¥15 关于华为5g模块mh5000-31接线问题
  • ¥15 keil L6007U报错