{
  "id": "go/goroutine-for-select-no-default",
  "signature": "fatal error: all goroutines are asleep - deadlock! (for-select with no default)",
  "signature_zh": "致命错误：所有协程都处于睡眠状态 - 死锁！（for-select没有default）",
  "regex": "fatal\\ error:\\ all\\ goroutines\\ are\\ asleep\\ \\-\\ deadlock!\\ \\(for\\-select\\ with\\ no\\ default\\)",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A for-select loop with no default case and all channels blocked causes goroutine to sleep forever.",
  "root_cause_type": "generic",
  "root_cause_zh": "一个没有default情况的for-select循环，所有通道都阻塞，导致协程永远睡眠。",
  "versions": [
    {
      "version": "1.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.20",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Adding time.Sleep inside loop",
      "why_fails": "Sleep doesn't unblock channels; goroutine still blocked.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "Using break statement to exit loop",
      "why_fails": "Break only exits select, not for loop; goroutine re-enters select and blocks again.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Add default case to avoid blocking",
      "success_rate": 0.95,
      "how": "for {\n    select {\n    case <-ch:\n        // handle\n    default:\n        // non-blocking\n    }\n}",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use a done channel to break out of loop",
      "success_rate": 0.9,
      "how": "done := make(chan struct{})\nfor {\n    select {\n    case <-ch:\n        // handle\n    case <-done:\n        return\n    }\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.84,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2025-04-18",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}