更新时间:2022-01-16 09:10:46
以下是在vscode中调试Revel框架(golang)应用的步骤.
Here are the steps to debug a revel framework (golang) app in vscode.
{
"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"]
}
]
}
{
"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)
Note that -importPath should be the directory (relative to $GOPATH\src where your project lives)
请注意,-srcPath的值应与$ GOPATH \ src目录匹配(我在Windows上运行)
Note that the value for -srcPath should match your $GOPATH\src directory (I'm running on Windows)
一旦这样设置了launch.json,就可以以deb模式启动该应用,并在任意位置放置断点.
Once your launch.json is set up as so, you can start the app in deb mode and put breakpoints wherever you wish.