如何在visual studio代码(vscode)中调试revel框架(golang)应用程序

时间:2016-12-15 18:56:56

标签: revel

{
"version": "0.2.0",
"configurations": [
    {
        "name": "Launch",
        "type": "go",
        "request": "attach",
        "mode": "debug",
        "remotePath": "",
        "port": 2345,
        "host": "127.0.0.1",
        "program": "revel.exe",
        "env": {},
        "args": [],
        "showLog": true
    },

]

}

如何在visual studio代码(vscode)中调试revel框架(golang)应用程序 如何编写配置文件(launch.json)

1 个答案:

答案 0 :(得分:0)

以下是在vscode中调试Revel框架(golang)应用的步骤。

  1. 将revel项目文件夹导入vscode
  2. 编辑〜/ .vscode / launch.json,使其类似于以下内容:(将<>中的值替换为您自己的本地环境的值。

{ "version": "0.2.0", "configurations": [ { "name": "Launch", "type": "go", "request": "launch", "remotePath": "", "port": 2345, "host": "127.0.0.1", "mode": "debug", "program": "${workspaceRoot}/app/tmp/", "env": {}, "args": ["-importPath", "<project folder name>", "-srcPath", "C:\\Users\\<username>\\go\\src", "-runMode", "dev"] } ] }

请注意-importPath应该是目录(相对于项目所在的$ GOPATH \ src)

请注意,-srcPath的值应与$ GOPATH \ src目录匹配(我在Windows上运行)

一旦这样设置了launch.json,就可以以deb模式启动该应用,并在任意位置放置断点。

enter image description here