2 回答

TA貢獻1998條經驗 獲得超6個贊
接下來是Microsoft/vscode-go 問題 219,并且仍然處于開放狀態。
是的 - VS Code 調試器控制臺當前不支持將任何輸入通過管道傳輸到 stdin。
僅供參考,您可以告訴代碼調試器在啟動配置中使用外部控制臺:
"externalConsole":?true
它有一個可能的解決方法,使用遠程調試+ vscode 任務,但這并不是微不足道的。
tasks.json
:
{
? ? // See https://go.microsoft.com/fwlink/?LinkId=733558
? ? // for the documentation about the tasks.json format
? ? "version": "2.0.0",
? ? "tasks": [
? ? ? ? {
? ? ? ? ? ? "label": "echo",
? ? ? ? ? ? "type": "shell",
? ? ? ? ? ? "command": "cd ${fileDirname} && dlv debug --headless --listen=:2345 --log --api-version=2",
? ? ? ? ? ? "problemMatcher": [],
? ? ? ? ? ? "group": {
? ? ? ? ? ? ? ? "kind": "build",
? ? ? ? ? ? ? ? "isDefault": true
? ? ? ? ? ? }
? ? ? ? }
? ? ]
}
launch.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": "launch",
? ? ? ? ? ? "mode": "remote",
? ? ? ? ? ? "remotePath": "${fileDirname}",
? ? ? ? ? ? "port": 2345,
? ? ? ? ? ? "host": "127.0.0.1",
? ? ? ? ? ? "program": "${fileDirname}",
? ? ? ? ? ? "env": {},
? ? ? ? ? ? "args": []
? ? ? ? }
? ? ]
}
使用快捷鍵(command/control + shift + B)運行任務,vscode 將啟動一個新的 shell 并運行 delve 服務器。
按 F5 調試 .go 文件。這對我來說可以。

TA貢獻1830條經驗 獲得超3個贊
要使用交互式控制臺,您可以包括
"console": "externalTerminal"
中launch.json
,而不是
"externalConsole": true
因為調試器可能不允許"externalConsole"
(就像我的情況一樣)
- 2 回答
- 0 關注
- 193 瀏覽
添加回答
舉報