'Cannot get "debug test" to work in VSCode (golang)

Debugging tests to work perfectly but at some point recently something changed, and now it doesn't (perhaps a go version upgrade?).

debug test image

When I click "debug test" this error message pops up:

Failed to launch: invalid debug configuration - cannot unmarshal bool into "env" of type string

The error is: Failed to launch: invalid debug configuration - cannot unmarshal bool into "env" of type string

My launch.json seems fine (again, this used to work perfectly):

{
"version": "0.2.0",
"configurations": [
    {
        "name": "Launch test function",
        "type": "go",
        "request": "launch",
        "mode": "test",
        "program": "${workspaceFolder}",
        "env": {
            "LOG_LEVEL": "debug",
            "LOG_SQL": "false",
            "DATABASE_URL": "postgresql://postgres@localhost:5432/chainlink_test?sslmode=disable",
        },
        "args": ["-v"]
    },
]

}

What could be wrong?



Solution 1:[1]

I had the same issue. I have CGO_ENABLED=0 in my global config. However, something is overriding and now expecting a String instead. Try something like this in your launch.json:

{
  [...]
  "env": {[...] "CGO_ENABLED": "0" [...]},
  [...]
},

Solution 2:[2]

Just a guess, but is it because “LOG_SQL” is “false” instead of false (string vs bool), and it’s trying to parse “false” to bool.

Solution 3:[3]

Have the same issue. Did solve by 
1. added line  "envFile": "${workspaceFolder}/.vscode/server.env" to launch.json
2. added file server.env into ${workspaceFolder}/.vscode/ with following content:
    LOG_LEVEL=debug 
    LOG_SQL=false
    DATABASE_URL=...
3. And removed env section from launch.json

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Justin Kloos
Solution 2 sbrichards
Solution 3