{
  "id": "go/flag-redefined",
  "signature": "flag redefined: -name",
  "signature_zh": "标志重复定义：-name",
  "regex": "flag redefined: -[a-zA-Z0-9_-]+",
  "domain": "go",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "The same flag name is registered twice via the flag package, typically due to importing two packages that define the same flag or calling flag.StringVar with the same name in multiple places.",
  "root_cause_type": "generic",
  "root_cause_zh": "通过flag包注册了相同的标志名称，通常是由于导入了两个定义相同标志的包，或在多个地方使用相同的名称调用flag.StringVar。",
  "versions": [
    {
      "version": "Go 1.18",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Go 1.19",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Go 1.20",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "This may break command-line interface consistency or cause confusion if the flag has a standard meaning.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The underlying cause (duplicate registration) still exists; pflag may also panic on duplicate definitions.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Define all flags in the main function or a single initialization function, and call flag.Parse() only once",
      "success_rate": 0.95,
      "how": "Define all flags in the main function or a single initialization function, and call flag.Parse() only once",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use flag.NewFlagSet to create separate flag sets for different packages or components",
      "success_rate": 0.9,
      "how": "Use flag.NewFlagSet to create separate flag sets for different packages or components",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Define all flags in the main function or a single initialization function, and call flag.Parse() only once",
    "Use flag.NewFlagSet to create separate flag sets for different packages or components"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://pkg.go.dev/flag#Var",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.84,
  "fix_success_rate": 0.87,
  "resolvable": "true",
  "first_seen": "2024-06-01",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}