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 } ] }
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"?
source to share
Yes it is possible.
- Let's pretend that
GOPATH
C:\Work\golang
- The project name is Revel
myapp
, so the project (workspace) location will beC:\Work\golang\src\myapp
. - Make some changes to the controllers etc.
- Launch the application with
revel run myapp
, then pressCTRL+C
to exit. This step is required to create the appropriate go files. The generated file i.e. The packagemain
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 parametersargs
, while the other parameters are not changed. -
Install
breakpoint
and run the debuggerdelve
...
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
source to share