How to debug interactive Go CLI command using VSCode?
- Posted on
- Authors
- Name
- ansidev
- @ansidev
Problem
By default, if you use the generated launch configuration template for debugging Golang application, it won’t work for debugging an interactive command.
Example launch configuration:
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/main.go"
}
]
}
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/main.go"
}
]
}
Error should contain this message: open /dev/tty: device not configured
.
Solutions
Add "console": "integratedTerminal"
to your current launch configuration.
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/main.go",
"console": "integratedTerminal"
}
]
}
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/main.go",
"console": "integratedTerminal"
}
]
}