英文:
Cannot set arguments for go app during debugging
问题
我正在尝试调试我的Goland应用程序,并且在launch.json文件中遇到了一些问题。我的应用程序应该使用参数运行:my_go_app -c path_to_config。
我的launch.json文件如下:
{
// 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 my go app",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}",
"args": ["-c /home/roman/projects/myapp/some.json"]
}
]
}
但是当我调试应用程序时,我收到了以下错误:
flag provided but not defined: -c /home/roman/projects/myapp/some.json
Usage of /tmp/__debug_bin542579318:
-c string
Specify the configuration file. (default "config.json")
在不进行调试的情况下,我的应用程序可以成功运行。请解释一下问题出在哪里...
英文:
I'm trying to debug my goland app and have some problems with launch.json file. My app should be run with argument: my_go_app -c path_to_config.
My launch.json looks like:
{
// 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 my go app",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}",
"args": ["-c /home/roman/projects/myapp/some.json"]
}
]
}
But when I debug app I have received the following error:
flag provided but not defined: -c /home/roman/projects/myapp/some.json
Usage of /tmp/__debug_bin542579318:
-c string
Specify the configuration file. (default "config.json")
Without debugging my app runs with success. Please explain what is wrong...
答案1
得分: 2
我已经找到问题所在。JSON应该像这样:
{
// 使用 IntelliSense 了解可能的属性。
// 悬停以查看现有属性的描述。
// 获取更多信息,请访问:https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "启动我的 Go 应用",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}",
"args": ["-c", "/home/roman/projects/myapp/some.json"]
}
]
}
英文:
I have found where is problem. The json should be like this:
{
// 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 my go app",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}",
"args": ["-c", "/home/roman/projects/myapp/some.json"]
}
]
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论