是否可以从 Visual Studio 代码调试 go revel 框架?
Is it possible to debug go revel framework from Visual Studio Code?
我正在尝试使用 visual studio 调试 Revel 应用程序,但无法正常工作。
我看过这个问题how to debug revel framework(golang) application in visual studio code(vscode)但还没有答案...
我试过这个配置:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "debug",
"remotePath": "",
"port": 2345,
"host": "127.0.0.1",
"program": "~/code/go/bin/revel",
"env": {},
"args": [],
"showLog": true
}
]
}
但是我收到了这个错误:
Failed to continue: "The program attribute must point to valid directory, .go file or executable."
我认为它一定是 rebel 二进制文件,这里是 运行,但我不知道如何传递应用程序路径,它应该进入 "args" 吗?
是的,这是可能的。
- 假设
GOPATH
是 C:\Work\golang
- Revel 项目名称为
myapp
,因此项目(工作区)的位置将为 C:\Work\golang\src\myapp
。
- 对控制器等进行一些更改...
- 运行应用
revel run myapp
,然后按CTRL+C
退出。这一步是生成相应的go文件所必需的。生成的文件,即 main
包将在 ${workspaceRoot}/app/tmp/main.go
下可用
配置launch.json
如下:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "debug",
"remotePath": "",
"port": 2345,
"host": "127.0.0.1",
"env": {},
"showLog": true,
"program": "${workspaceRoot}/app/tmp/",
"args": ["-importPath", "myapp", "-srcPath", "c:\work\golang\src", "-runMode", "dev"]
}
]
}
重要的部分是program
和args
参数,其他参数不用修改。
设置breakpoint
并启动delve
调试器...
编辑:
- 将
args
参数设置为 ["-importPath", "myapp", "-srcPath", "${workspaceRoot}/..", "-runMode", "dev"]
也有效,我认为这在其他平台(Mac、Linux)中也应该有效。
- 错误消息与
delve
问题有关。参见 https://github.com/Microsoft/vscode-go/issues/986
我正在尝试使用 visual studio 调试 Revel 应用程序,但无法正常工作。
我看过这个问题how to debug revel framework(golang) application in visual studio code(vscode)但还没有答案...
我试过这个配置:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "debug",
"remotePath": "",
"port": 2345,
"host": "127.0.0.1",
"program": "~/code/go/bin/revel",
"env": {},
"args": [],
"showLog": true
}
]
}
但是我收到了这个错误:
Failed to continue: "The program attribute must point to valid directory, .go file or executable."
我认为它一定是 rebel 二进制文件,这里是 运行,但我不知道如何传递应用程序路径,它应该进入 "args" 吗?
是的,这是可能的。
- 假设
GOPATH
是C:\Work\golang
- Revel 项目名称为
myapp
,因此项目(工作区)的位置将为C:\Work\golang\src\myapp
。 - 对控制器等进行一些更改...
- 运行应用
revel run myapp
,然后按CTRL+C
退出。这一步是生成相应的go文件所必需的。生成的文件,即main
包将在${workspaceRoot}/app/tmp/main.go
下可用
配置
launch.json
如下:{ "version": "0.2.0", "configurations": [ { "name": "Launch", "type": "go", "request": "launch", "mode": "debug", "remotePath": "", "port": 2345, "host": "127.0.0.1", "env": {}, "showLog": true, "program": "${workspaceRoot}/app/tmp/", "args": ["-importPath", "myapp", "-srcPath", "c:\work\golang\src", "-runMode", "dev"] } ] }
重要的部分是
program
和args
参数,其他参数不用修改。设置
breakpoint
并启动delve
调试器...
编辑:
- 将
args
参数设置为["-importPath", "myapp", "-srcPath", "${workspaceRoot}/..", "-runMode", "dev"]
也有效,我认为这在其他平台(Mac、Linux)中也应该有效。 - 错误消息与
delve
问题有关。参见 https://github.com/Microsoft/vscode-go/issues/986