英文:
Cannot get "debug test" to work in VSCode (golang)
问题
调试测试以前是完美运行的,但最近某个时刻发生了一些变化,现在不再工作(可能是Go版本升级了?)。
当我点击“debug test”时,出现了以下错误信息:
错误信息为:Failed to launch: invalid debug configuration - cannot unmarshal bool into "env" of type string
我的 launch.json
看起来没问题(再次强调,以前是完美运行的):
{
"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"]
},
]
}
可能出了什么问题?
英文:
Debugging tests to work perfectly but at some point recently something changed, and now it doesn't (perhaps a go version upgrade?).
When I click "debug test" this error message pops up:
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?
答案1
得分: 2
我遇到了同样的问题。我在我的全局配置中设置了CGO_ENABLED=0
。然而,有些东西正在覆盖这个设置,现在期望的是一个字符串。在你的launch.json
文件中尝试像这样设置:
{
[...]
"env": {[...] "CGO_ENABLED": "0" [...]},
[...]
},
英文:
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" [...]},
[...]
},
答案2
得分: 0
只是猜测,是因为"LOG_SQL"是"false"而不是false(字符串 vs 布尔值),它试图将"false"解析为布尔值。
英文:
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.
答案3
得分: 0
遇到了同样的问题。通过以下步骤解决:
- 在 launch.json 中添加一行代码:"envFile": "${workspaceFolder}/.vscode/server.env"
- 在 ${workspaceFolder}/.vscode/ 目录下创建 server.env 文件,并添加以下内容:
LOG_LEVEL=debug
LOG_SQL=false
DATABASE_URL=... - 从 launch.json 中删除 env 部分。
英文:
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
答案4
得分: 0
我遇到了同样的问题,结果发现是因为我的 settings.json 中有一个键/值对,其中值是一个数字。我将其转换为字符串后,问题就解决了。我原以为在调试时只有 launch.json 被使用,但看来并非如此。
英文:
I had the same issue and it turns out it was because of a key/value pair in my settings.json where the value was a number. I turned it into a string and it worked fine. I though VS code only used the launch.json when debugging, but I guess not.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论