how to debug revel framework(golang) application in visual studio code(vscode)

梦想与她 提交于 2019-12-12 17:39:11

问题


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

]

}

how to debug revel framework(golang) application in visual studio code(vscode) how to write the configuration file(launch.json)


回答1:


Here are the steps to debug a revel framework (golang) app in vscode.

  1. Import revel project folder into vscode
  2. Edit ~/.vscode/launch.json so that it looks like the following: (replace values in <> with values for your own local env.

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

Note that -importPath should be the directory (relative to $GOPATH\src where your project lives)

Note that the value for -srcPath should match your $GOPATH\src directory (I'm running on Windows)

Once your launch.json is set up as so, you can start the app in deb mode and put breakpoints wherever you wish.



来源:https://stackoverflow.com/questions/41171432/how-to-debug-revel-frameworkgolang-application-in-visual-studio-codevscode

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!