无法启动 dlv dap
Couldn't start dlv dap
当我在 VSCode dlv dap 调试中启动时,我收到此消息:
Couldn't start dlv dap:
Error:timed out while waiting for DAP server to start
我已经有项目的启动配置:
lunch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch file",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceFolder}",
"showLog": true,
"env": {
"GO111MODULE": "on"
}
}
]
}
和setting.json是:
{
"folders": [
{
"path": "."
}
],
"settings": {
"go.useCodeSnippetsOnFunctionSuggestWithoutType": true,
"go.autocompleteUnimportedPackages": true,
"go.gocodePackageLookupMode": "go",
"go.gotoSymbol.includeImports": true,
"go.useCodeSnippetsOnFunctionSuggest": true,
"explorer.confirmDelete": false,
"go.formatTool": "goimports",
"go.docsTool": "gogetdoc",
"go.buildFlags": [],
"explorer.confirmDragAndDrop": false,
"window.zoomLevel": 0.8,
"editor.minimap.enabled": false,
"go.useLanguageServer": true,
"go.delveConfig":{
"debugAdapter":"dlv-dap"
},
"[go]": {
"editor.snippetSuggestions": "none",
"editor.formatOnType": true,
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
},
"gopls": {
"experimentalWorkspaceModule": true,
"usePlaceholders": true, // add parameter placeholders when completing a function
"completionDocumentation": true // for documentation in completion items
}
},
}
项目结构如图:
您可能运气好将 delveConfig 切换为使用旧模式:
"go.delveConfig":{
"debugAdapter":"legacy"
}
我和我的团队最近在更新 VSCode 后开始遇到同样的问题。这里有一些关于此设置的更多信息:https://go.googlesource.com/vscode-go/+/HEAD/docs/debugging.md#switching-to-legacy-debug-adapter,但我相信根本原因(如果这确实解决了您的问题)将是您的 Golang 版本不是 dlv-dap 的目标版本。 Go 1.15 以下版本需要使用 legacy 模式,而最新版本的 delve 调试器现在默认跳过 legacy 模式。
我还需要杀死 VSCode 才能使此更改生效。根据 dlv-dap 文档,您还可以通过将 launch.json 的模式切换为“远程”来强制其进入传统模式,因此可能有一些(也许更好)的方法可以解决此问题。
这可能是由于最近更新了 VS Code Go extension。
第一个选项是通过命令面板中的运行 "Go: Install/Update Tools"
命令来修复它(Linux/Windows: Ctrl+Shift+P, Mac: ⇧+⌘+ P).
然后,在菜单中标记 dlv
& dlv-dap
,然后点击 确定 开始 install/update。
Delve’s native DAP implementation is under active development, so take advantage of the most recent features and bug fixes by using Delve built from its master branch. The Go extension maintains this newest version of Delve separately from the officially released version of dlv and installs it with the name dlv-dap.
第二个选项,是使用旧版调试适配器。在下面的 link 中有更多相关信息...
在 https://github.com/golang/vscode-go/blob/master/docs/debugging.md
查看完整文档
对于 macOS 用户:
brew install delve
Linux/Windows:Ctrl+Shift+P,Mac:⇧+⌘+P
当我在 VSCode dlv dap 调试中启动时,我收到此消息:
Couldn't start dlv dap:
Error:timed out while waiting for DAP server to start
我已经有项目的启动配置:
lunch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch file",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceFolder}",
"showLog": true,
"env": {
"GO111MODULE": "on"
}
}
]
}
和setting.json是:
{
"folders": [
{
"path": "."
}
],
"settings": {
"go.useCodeSnippetsOnFunctionSuggestWithoutType": true,
"go.autocompleteUnimportedPackages": true,
"go.gocodePackageLookupMode": "go",
"go.gotoSymbol.includeImports": true,
"go.useCodeSnippetsOnFunctionSuggest": true,
"explorer.confirmDelete": false,
"go.formatTool": "goimports",
"go.docsTool": "gogetdoc",
"go.buildFlags": [],
"explorer.confirmDragAndDrop": false,
"window.zoomLevel": 0.8,
"editor.minimap.enabled": false,
"go.useLanguageServer": true,
"go.delveConfig":{
"debugAdapter":"dlv-dap"
},
"[go]": {
"editor.snippetSuggestions": "none",
"editor.formatOnType": true,
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
},
"gopls": {
"experimentalWorkspaceModule": true,
"usePlaceholders": true, // add parameter placeholders when completing a function
"completionDocumentation": true // for documentation in completion items
}
},
}
项目结构如图:
您可能运气好将 delveConfig 切换为使用旧模式:
"go.delveConfig":{
"debugAdapter":"legacy"
}
我和我的团队最近在更新 VSCode 后开始遇到同样的问题。这里有一些关于此设置的更多信息:https://go.googlesource.com/vscode-go/+/HEAD/docs/debugging.md#switching-to-legacy-debug-adapter,但我相信根本原因(如果这确实解决了您的问题)将是您的 Golang 版本不是 dlv-dap 的目标版本。 Go 1.15 以下版本需要使用 legacy 模式,而最新版本的 delve 调试器现在默认跳过 legacy 模式。
我还需要杀死 VSCode 才能使此更改生效。根据 dlv-dap 文档,您还可以通过将 launch.json 的模式切换为“远程”来强制其进入传统模式,因此可能有一些(也许更好)的方法可以解决此问题。
这可能是由于最近更新了 VS Code Go extension。
第一个选项是通过命令面板中的运行 "Go: Install/Update Tools"
命令来修复它(Linux/Windows: Ctrl+Shift+P, Mac: ⇧+⌘+ P).
然后,在菜单中标记 dlv
& dlv-dap
,然后点击 确定 开始 install/update。
Delve’s native DAP implementation is under active development, so take advantage of the most recent features and bug fixes by using Delve built from its master branch. The Go extension maintains this newest version of Delve separately from the officially released version of dlv and installs it with the name dlv-dap.
第二个选项,是使用旧版调试适配器。在下面的 link 中有更多相关信息...
在 https://github.com/golang/vscode-go/blob/master/docs/debugging.md
查看完整文档对于 macOS 用户:
brew install delve
Linux/Windows:Ctrl+Shift+P,Mac:⇧+⌘+P