Debugging VS代码调试golang。深入调试程序

Debugging VS代码调试golang。深入调试程序,debugging,go,visual-studio-code,Debugging,Go,Visual Studio Code,我对VisualStudio代码中的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": [

我对VisualStudio代码中的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
    }
]
根据您安装delve的方式,它可能会出现在您的路径中,或者 GOPATH/bin。如果dlv二进制文件在您的GOPATH/bin中,而此GOPATH不在 设置为环境变量,然后确保路径指向 这个GOPATH/bin,这样Go扩展可以找到dlv二进制文件

尝试将目录更改为filename,以从项目文件夹的
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(例如as~/.go) 在终端上运行命令

go env
检查
GOROOT
GOPATH
变量,查看delve是否与它们同步


有关签出的详细信息

这可能是因为您的工作区根路径与您打开的目录不同。您是否尝试根据我的回答更改设置,然后从
main运行代码。转到
Yes,但它不起作用。我在下面写了一篇帖子,当你运行调试器时,它是否在
问题
调试控制台
time=“2018-06-23T21:01:55+02:00”level=info msg=“启动带有参数的进程:[c:\\Users\\Lenovo\\go\\src\\hello\\DEBUG]”layer=debugger