增加 VSCode 调试 Golang 无法 Input 问题的解决.

Signed-off-by: chen.yang <chen.yang@yuzhen-iot.com>
This commit is contained in:
chen.yang 2021-11-26 10:29:42 +08:00
parent 44200bf8b2
commit 70a869f551
1 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1,29 @@
# VSCode 调试 Golang 无法 Input 问题的解决
解决办法就是不用 VSCode 的调试终端,在命令行里使用 DLV 开启服务,然后使用 VSCode 作为调试 Client 进行连接,则可在 DLV 调试命令行里输入
```bash
dlv debug --headless --listen=:2345 --api-version=2 <program>
```
VSCode 的 launch.json 如下:
```json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Connect to server",
"type": "go",
"request": "attach",
"mode": "remote",
"remotePath": "${workspaceFolder}",
"port": 2345,
"host": "127.0.0.1"
}
]
}
```