dongren4147 2017-06-16 12:58
浏览 573
已采纳

是否可以从Visual Studio Code调试go revel框架?

I'm trying to debug a revel app with visual studio but I can't get it to work.

I've seen this question how to debug revel framework(golang) application in visual studio code(vscode) but no answers yet...

I've tried with this config:

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Launch",
      "type": "go",
      "request": "launch",
      "mode": "debug",
      "remotePath": "",
      "port": 2345,
      "host": "127.0.0.1",
      "program": "~/code/go/bin/revel",
      "env": {},
      "args": [],
      "showLog": true
    }
  ]
}

But I'm getting this error: Failed to continue: "The program attribute must point to valid directory, .go file or executable."

I think it must be the rebel binary the one to be run here, but I don't know how to pass the app path, should it go in "args"?

</div>
  • 写回答

1条回答 默认 最新

  • dongnao2048 2017-06-16 16:56
    关注

    Yes it's possible.

    1. Suppose that the GOPATH is C:\Work\golang
    2. Revel project name is myapp, thus the location of the project (workspace) will be C:\Work\golang\src\myapp.
    3. Make some changes to the controllers etc...
    4. Run the application with revel run myapp, then press CTRL+C to exit. This step is necessary to generate corresponding go files. The generated file, i.e. the main package will be available under ${workspaceRoot}/app/tmp/main.go
    5. Configure launch.json as follows:

      {
          "version": "0.2.0",
          "configurations": [
              {
                  "name": "Launch",
                  "type": "go",
                  "request": "launch",
                  "mode": "debug",
                  "remotePath": "",
                  "port": 2345,
                  "host": "127.0.0.1",
                  "env": {},
                  "showLog": true,
                  "program": "${workspaceRoot}/app/tmp/",
                  "args": ["-importPath", "myapp", "-srcPath", "c:\\work\\golang\\src",  "-runMode", "dev"]
              }
          ]
      }
      
    6. The important parts are program and args parameters, while the other parameters are unmodified.

    7. Set breakpoint and start the delve debugger...

    Debug revel application

    EDIT:

    1. Setting args parameter to ["-importPath", "myapp", "-srcPath", "${workspaceRoot}/..", "-runMode", "dev"] also work, and I think this should work in other platforms (Mac, Linux) too.
    2. The error message is related to delve issue. See https://github.com/Microsoft/vscode-go/issues/986
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Matlab怎么求解含参的二重积分?
  • ¥15 苹果手机突然连不上wifi了?
  • ¥15 cgictest.cgi文件无法访问
  • ¥20 删除和修改功能无法调用
  • ¥15 kafka topic 所有分副本数修改
  • ¥15 小程序中fit格式等运动数据文件怎样实现可视化?(包含心率信息))
  • ¥15 如何利用mmdetection3d中的get_flops.py文件计算fcos3d方法的flops?
  • ¥40 串口调试助手打开串口后,keil5的代码就停止了
  • ¥15 电脑最近经常蓝屏,求大家看看哪的问题
  • ¥60 高价有偿求java辅导。工程量较大,价格你定,联系确定辅导后将采纳你的答案。希望能给出完整详细代码,并能解释回答我关于代码的疑问疑问,代码要求如下,联系我会发文档