{
  "id": "go/flag-parse-unexpected-value",
  "signature": "flag: -flag needs an argument: -value",
  "signature_zh": "flag: -flag 需要一个参数：-value",
  "regex": "flag: -[a-zA-Z]+ needs an argument: -[a-zA-Z]+",
  "domain": "go",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "A boolean flag or a flag expecting a value is followed by another flag without a value separator, causing the next flag to be interpreted as the value.",
  "root_cause_type": "generic",
  "root_cause_zh": "一个布尔标志或期望值的标志后面跟着另一个标志而没有值分隔符，导致下一个标志被解释为值。",
  "versions": [
    {
      "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"
    },
    {
      "version": "go1.23",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Adding = between flag and value: -flag=value",
      "why_fails": "This works for flags expecting values, but if the flag is defined as bool, it still fails because bool flags don't take values.",
      "fail_rate": 0.4,
      "condition": "",
      "sources": []
    },
    {
      "action": "Using double dashes --flag value",
      "why_fails": "Go's flag package treats -- as prefix for long flags; it doesn't change the parsing behavior for value requirement.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Provide the value after a space: -flag value, or use =: -flag=value. Ensure the flag type matches (e.g., int, string).",
      "success_rate": 0.95,
      "how": "Provide the value after a space: -flag value, or use =: -flag=value. Ensure the flag type matches (e.g., int, string).",
      "condition": "",
      "sources": []
    },
    {
      "action": "If the flag is meant to be boolean, define it as bool and don't pass a value: flag.Bool(\"flag\", false, \"usage\")",
      "success_rate": 0.9,
      "how": "If the flag is meant to be boolean, define it as bool and don't pass a value: flag.Bool(\"flag\", false, \"usage\")",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "在空格后提供值：-flag value，或使用 =：-flag=value。确保标志类型匹配（例如 int、string）。",
    "如果标志应为布尔型，将其定义为 bool 且不传递值：flag.Bool(\"flag\", false, \"usage\")"
  ],
  "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.84,
  "fix_success_rate": 0.88,
  "resolvable": "true",
  "first_seen": "2024-04-05",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}