I usually run go test ./... to run all tests in my project.
How can I set up launch.json to debug every tests that normally go test ./... runs?
I usually run go test ./... to run all tests in my project.
How can I set up launch.json to debug every tests that normally go test ./... runs?
Assuming you're using the Go extension for VSCode:
As the vscode-go's documentation says, you could use the following:
{
"name": "Launch test package",
"type": "go",
"request": "launch",
"mode": "test",
"program": "${workspaceFolder}"
}
Note that you're specifying a new mode called "test".
You have to install delve in order to debug code using VSCode. You can install it by yourself or use the Go: Install/Update Tools command from VSCode. Read the documentation I mention first for more information.
workspaceFolder but not tests in the folders under it!