{
  "id": "go/goroutine-panic-uncaught",
  "signature": "panic: runtime error: index out of range [5] with length 5 (in goroutine)",
  "signature_zh": "恐慌：运行时错误：索引超出范围 [5]，长度为 5（在 goroutine 中）",
  "regex": "panic:\\ runtime\\ error:\\ index\\ out\\ of\\ range\\ \\[5\\]\\ with\\ length\\ 5\\ \\(in\\ goroutine\\)",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A goroutine accesses an array or slice index that is out of bounds, causing a panic that is not recovered, crashing the entire program.",
  "root_cause_type": "generic",
  "root_cause_zh": "goroutine 访问数组或切片的越界索引，导致恐慌未被恢复，整个程序崩溃。",
  "versions": [
    {
      "version": "1.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.23",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Adding recover in main but not in the goroutine",
      "why_fails": "Panic in goroutine is not caught by main's recover unless deferred in the goroutine itself.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "Using a larger array but not fixing the index logic",
      "why_fails": "Band-aid solution; index may still go out of bounds in other cases.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Add a deferred recover inside the goroutine to handle panics gracefully",
      "success_rate": 0.9,
      "how": "go func() {\n    defer func() {\n        if r := recover(); r != nil {\n            log.Printf(\"Recovered in goroutine: %v\", r)\n        }\n    }()\n    arr := make([]int, 5)\n    arr[5] = 10 // panic here\n}()",
      "condition": "",
      "sources": []
    },
    {
      "action": "Check slice bounds before accessing",
      "success_rate": 0.95,
      "how": "arr := make([]int, 5)\nindex := 5\nif index < len(arr) {\n    arr[index] = 10\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.86,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-08-22",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}