Is it possible to debug a revel framework from Visual Studio Code?

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

I saw this question how to debug a revel framework (golang) app in Visual Studio Code (vscode) but there are no answers yet ...

I've tried this configuration:

{
  "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
    }
  ]
}
      

Run codeHide result


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

I think it should be a binary bitbal to run here, but I don't know how to pass the path to it if it goes to "args"?

+3


source to share


1 answer


Yes it is possible.

  • Let's pretend that GOPATH

    C:\Work\golang

  • The project name is Revel myapp

    , so the project (workspace) location will be C:\Work\golang\src\myapp

    .
  • Make some changes to the controllers etc.
  • Launch the application with revel run myapp

    , then press CTRL+C

    to exit. This step is required to create the appropriate go files. The generated file i.e. The package main

    will be available under${workspaceRoot}/app/tmp/main.go

  • 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"]
            }
        ]
    }
    
          

  • The important parts are the program

    and parameters args

    , while the other parameters are not changed.

  • Install breakpoint

    and run the debugger delve

    ...

Debug debug app



EDIT:

  • The parameter args

    for ["-importPath", "myapp", "-srcPath", "${workspaceRoot}/..", "-runMode", "dev"]

    also works, and I think it should work on other platforms as well (Mac, Linux).
  • The error message is related to a problem delve

    . See https://github.com/Microsoft/vscode-go/issues/986
+4


source







All Articles