带有VSCODE的Golang调试测试的问题
我正在使用一些全局变量在VSCODE上运行Golang测试,这些变量是在达到测试功能之前初始化的。
我程序中的全局变量从lunaine.json文件(os.args)中指定的Runline参数获得其值。
由于某种原因,当我运行测试时,我的ARG与启动.json文件中指定的ARG不同。
这些是我的启动文件的内容:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch file",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${file}",
"args": [".", "from", "to", "csv", "hl7"]
}
]
}
这些是我经常获得的不同值:
os.Args[0] = //path to the __debug_bin.exe
os.Args[1] = "-test.run"
os.Args[2] = "^TestInit$"
在我的启动。JSON文件中,我总共有6个参数,这使我在尝试运行测试时会出现界限。
因此,我的问题是如何更改它,以便测试在启动文件中指定的参数运行?
I'm running Golang tests on VSCode with some global variables, that being initialized before reaching the test function.
The global variables in my program get their values from runline arguments, that specified in the launch.json file (os.Args).
For some reason when I'm running tests I have different args than the ones specified in the launch.json file.
These are contents of my launch file:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch file",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${file}",
"args": [".", "from", "to", "csv", "hl7"]
}
]
}
These are the different values that I constantly get:
os.Args[0] = //path to the __debug_bin.exe
os.Args[1] = "-test.run"
os.Args[2] = "^TestInitquot;
In my launch.json file I have 6 arguments in total, which leads me to an out of bounds error when I try to run tests.
So my question is how do change it so that tests run with the arguments I specified in the launch file?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Codelens现在不支持此功能,请在此处检查 codelens:一种使用选定的启动的方式。跑步测试中的JSON配置|调试
但是您可以喜欢此
“ go.testflags”:[“ - v”,“ -args”,“从”,“到”,“ CSV”,“ HL7”] 在用户设置(文件路径)中“代码\ user \ settings.json”
,您可以这样检查
。
codelens does not support this feature for now please check here codelens: a way to use selected launch.json configuration in run test | debug
But you can do like this
"go.testFlags": ["-v", "-args", "from", "to", "csv", "hl7"]
in user setting (path for file) "Code\User\settings.json"and you can check like this
....