Go VS Code 调式常见问题处理

时间:2023-03-09 22:58:38
Go VS Code 调式常见问题处理

GO VS Code 调式配置

launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "debug",
"remotePath": "",
"port": 2345,
"host": "127.0.0.1",
"program": "${fileDirname}",
"env": {
"GOPATH":"D:\\项目目录;D:\\项目目录1;"
},
"args": [],
"showLog": true
}
]
}

Failded to continue:"Cannot find Delve debugger. Install from https://github.com/derekparker/delve & ensure it is in your "GOPATH/bin" or "PATH" 错误处理

或VS Code 终端:go get github.com/derekparker/delve/cmd/dlv

多项目调试

launch.json
        {
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "debug",
"remotePath": "",
"port": 2345,
"host": "127.0.0.1",
"program": "${fileDirname}",
"env": {
"GOPATH":"E:\\GoFouxucPrivateRoomPorject\\"
},
"args": [],
"showLog": true
},
{
"name": "Launch2",
"type": "go",
"request": "launch2",
"mode": "debug",
"remotePath": "",
"port": 2345,
"host": "127.0.0.1",
"program": "${fileDirname}",
"env": {
"GOPATH":"E:\\GoFouxucPrivateRoomPorject\\"
},
"args": [],
"showLog": true
}