{
  "id": "go/flag-provided-but-not-defined",
  "signature": "flag provided but not defined: -foo",
  "signature_zh": "提供了标志但未定义：-foo",
  "regex": "flag provided but not defined: -([a-zA-Z0-9_-]+)",
  "domain": "go",
  "category": "build_error",
  "subcategory": null,
  "root_cause": "A command-line flag passed to a Go program that does not have a corresponding flag definition using the flag package.",
  "root_cause_type": "generic",
  "root_cause_zh": "向 Go 程序传递的命令行标志没有使用 flag 包进行相应的标志定义。",
  "versions": [
    {
      "version": "go1.20",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "go1.21",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "go1.22",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Change the flag name in the command line to match an existing flag",
      "why_fails": "May not be the intended flag; could cause incorrect behavior if the wrong flag is used",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "Ignore the error and continue execution by catching it",
      "why_fails": "flag.Parse() terminates on undefined flags; cannot be ignored",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "Use a third-party flag library that doesn't report this error",
      "why_fails": "Switching libraries may introduce compatibility issues and doesn't fix the missing definition",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Define the flag before parsing: var foo string; flag.StringVar(&foo, \"foo\", \"\", \"usage\"); flag.Parse()",
      "success_rate": 0.97,
      "how": "Define the flag before parsing: var foo string; flag.StringVar(&foo, \"foo\", \"\", \"usage\"); flag.Parse()",
      "condition": "",
      "sources": []
    },
    {
      "action": "If the flag is from a third-party tool, check its documentation and add the correct flag definition",
      "success_rate": 0.95,
      "how": "If the flag is from a third-party tool, check its documentation and add the correct flag definition",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use flag.VisitAll() to list all defined flags and verify the intended flag exists",
      "success_rate": 0.9,
      "how": "Use flag.VisitAll() to list all defined flags and verify the intended flag exists",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "在解析前定义标志：var foo string; flag.StringVar(&foo, \"foo\", \"\", \"用法\"); flag.Parse()",
    "如果标志来自第三方工具，请查阅其文档并添加正确的标志定义",
    "使用 flag.VisitAll() 列出所有已定义的标志，并验证预期的标志是否存在"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://pkg.go.dev/flag#FlagSet.Parse",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.88,
  "fix_success_rate": 0.97,
  "resolvable": "true",
  "first_seen": "2023-04-05",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}