【问题标题】:Cannot set arguments for go app during debugging调试期间无法为 go app 设置参数
【发布时间】:2021-10-26 11:30:30
【问题描述】:

我正在尝试调试我的 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"]
        }
    ]
}

但是当我调试应用程序时,我收到了以下错误:

提供但未定义的标志:-c /home/roman/projects/myapp/some.json /tmp/__debug_bin542579318 的用法: -c 字符串 指定配置文件。 (默认“config.json”)

没有调试我的应用程序运行成功。请解释什么是错的......

【问题讨论】:

    标签: go visual-studio-code vscode-debugger


    【解决方案1】:

    我发现问题出在哪里。 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"]
            }
        ]
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-11-12
      • 1970-01-01
      • 2020-02-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-12-30
      • 2022-06-14
      相关资源
      最近更新 更多