问题
{
"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.
- Import revel project folder into vscode
- 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