Skip to content

Share this post

paypalkofibuymeacoffeemomo

How to debug interactive Go CLI command using VSCode?

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:

json
{
  "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.

json
{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Debug",
      "type": "go",
      "request": "launch",
      "mode": "auto",
      "program": "${workspaceFolder}/main.go",
      "console": "integratedTerminal"
    }
  ]
}

References