使用 vscode 调试 revel 程序的配置如下:
.vscode/launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "revel",
"type": "go",
"request": "launch",
"mode": "auto",
"remotePath": "",
"port": 2345,
"host": "127.0.0.1",
"env": {},
"showLog": false,
// 启动调试之前先调用 revel build 任务根据配置生成所需源代码
"preLaunchTask": "revel build",
// 在此指定 revel 生成的 main.go 所在目录
"program": "${workspaceRoot}/app/tmp/",
// 启动 revel 程序的参数
"args": ["-importPath", "github.com/my-app/my-app", "-srcPath", "${workspaceRoot}/..", "-runMode", "dev"]
}
]
}
.vscode/tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "revel build",
"type": "shell",
"command": "revel build github.com/my-app/my-app /tmp/my-app dev"
}
]
}