Debugging Go tests in Visual Studio Code

To launch debugger for test I added one more configuration for launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Code",
            "type": "go",
            "request": "launch",
            "mode": "debug",
            "remotePath": "",
            "port": 2345,
            "host": "127.0.0.1",
            "program": "${workspaceRoot}",
            "env": {},
            "args": [],
            "showLog": true
        },
        {
            "name": "Test Current File",
            "type": "go",
            "request": "launch",
            "mode": "test",
            "remotePath": "",
            "port": 2345,
            "host": "127.0.0.1",
            "program": "${file}",
            "env": {},
            "args": [],
            "showLog": true
        }       
    ]
}

Also this configuration does not support tags. All tags in test files have to be disabled

// +build unit
...

Leave a Comment