gpt4 book ai didi

debugging - VSCode 调试 golang。深入调试器

转载 作者:IT王子 更新时间:2023-10-29 01:40:57 24 4
gpt4 key购买 nike

我在使用 Visual Studio Code 中的 Delve 调试器时遇到问题。调试开始但没有任何反应。控制台中只有信息:

time="2018-06-23T16:35:55+02:00" level=info msg="launching process with args: [C:\\Users\\LenovoPC\\go\\src\\test\\debug]" layer=debugger

launch.json的配置

"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "debug",
"remotePath": "",
"port": 2345,
"host": "127.0.0.1",
"program": "${workspaceRoot}",
"env": {},
"args": [],
"showLog": true
}
]

最佳答案

Based on how you install delve it will either end up in your PATH or GOPATH/bin. If dlv binary is in your GOPATH/bin and this GOPATH is not set as an environment variable, then make sure your PATH points to this GOPATH/bin so that the Go extension can find the dlv binary.

尝试将目录更改为文件名以从项目文件夹的 main.go 运行项目

{
"version": "0.2.0",
"configurations": [

{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "debug",
"remotePath": "",
"port": 2345,
"host": "127.0.0.1",
"program": "${fileDirname}",
"env": {},
"args": [],
"showLog": true
}
]
}

确保 $GOPATH 已设置(例如 ~/.go)在终端运行命令

go env

检查 GOROOTGOPATH 变量以查看 delve 是否与它们同步

有关更多信息,请查看 How to configure Delve

关于debugging - VSCode 调试 golang。深入调试器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51002196/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com