{
  "id": "go/goroutine-panic-in-goroutine",
  "signature": "panic: runtime error: index out of range [5] with length 3 (in goroutine)",
  "signature_zh": "恐慌：运行时错误：索引超出范围 [5] 长度为3（在协程中）",
  "regex": "panic:\\ runtime\\ error:\\ index\\ out\\ of\\ range\\ \\[5\\]\\ with\\ length\\ 3\\ \\(in\\ goroutine\\)",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Goroutine accesses slice or array with out-of-bounds index, causing panic that crashes the entire program if not recovered.",
  "root_cause_type": "generic",
  "root_cause_zh": "协程使用越界索引访问slice或数组，导致恐慌，如果不恢复则崩溃整个程序。",
  "versions": [
    {
      "version": "1.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.22",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Ignoring panic and hoping it doesn't happen",
      "why_fails": "Panic crashes the program; cannot be ignored.",
      "fail_rate": 1.0,
      "condition": "",
      "sources": []
    },
    {
      "action": "Using recover() in main goroutine only",
      "why_fails": "Recover must be called in the same goroutine that panicked; main goroutine cannot recover from child goroutine panic.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Use recover() inside the goroutine to handle panic",
      "success_rate": 0.9,
      "how": "go func() {\n    defer func() {\n        if r := recover(); r != nil {\n            log.Println(\"recovered from panic:\", r)\n        }\n    }()\n    arr := []int{1,2,3}\n    fmt.Println(arr[5])\n}()",
      "condition": "",
      "sources": []
    },
    {
      "action": "Always check bounds before accessing slice",
      "success_rate": 0.95,
      "how": "if idx < len(arr) {\n    fmt.Println(arr[idx])\n} else {\n    log.Println(\"index out of bounds\")\n}",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.87,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2025-03-12",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}