{
  "id": "go/http-handler-panic-recovery",
  "signature": "panic: http: panic serving 127.0.0.1:8080: runtime error: index out of range",
  "signature_zh": "panic: http: 服务 127.0.0.1:8080 时 panic: 运行时错误：索引越界",
  "regex": "panic:\\ http:\\ panic\\ serving\\ 127\\.0\\.0\\.1:8080:\\ runtime\\ error:\\ index\\ out\\ of\\ range",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "HTTP handler 中发生未捕获的 panic，导致服务器崩溃，默认 net/http 会恢复但记录日志。",
  "root_cause_type": "generic",
  "root_cause_zh": "处理请求时访问无效索引，未使用 recover 捕获，导致服务中断。",
  "versions": [
    {
      "version": "1.21",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "连接会中断，且可能泄漏资源",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "recover 必须在 panic 发生的 goroutine 中调用，handler 外无效",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "在 handler 内部使用 defer recover() 并记录日志",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "使用中间件统一处理 panic，返回 500 错误",
      "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-06-01",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}