{
  "id": "go/goroutine-sleep-in-loop",
  "signature": "warning: goroutine sleeping in loop (goroutine 9)",
  "signature_zh": "警告：goroutine 在循环中休眠（goroutine 9）",
  "regex": "warning:\\ goroutine\\ sleeping\\ in\\ loop\\ \\(goroutine\\ 9\\)",
  "domain": "go",
  "category": "resource_error",
  "subcategory": null,
  "root_cause": "A goroutine calls time.Sleep in a tight loop, consuming resources and potentially blocking.",
  "root_cause_type": "generic",
  "root_cause_zh": "goroutine 在紧密循环中调用 time.Sleep，消耗资源并可能阻塞。",
  "versions": [
    {
      "version": "1.20",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Still busy-waits; doesn't solve the underlying issue.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Gosched doesn't block; it just yields, but loop continues.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Wastes CPU and may cause performance issues.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "ticker := time.NewTicker(time.Second)\ndefer ticker.Stop()\nfor range ticker.C {\n    // do work\n}",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "select {\ncase <-time.After(time.Second):\n    // do work\ncase <-ctx.Done():\n    return\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.82,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-09-14",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}