{
  "id": "go/http-superfluous-writeheader",
  "signature": "http: superfluous response.WriteHeader call from main.handler (server.go:42)",
  "signature_zh": "http：多余的 response.WriteHeader 调用，来自 main.handler（server.go:42）",
  "regex": "http:\\ superfluous\\ response\\.WriteHeader\\ call\\ from\\ main\\.handler\\ \\(server\\.go:42\\)",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "WriteHeader is called more than once, or Write is called before WriteHeader. Only the first status code is sent.",
  "root_cause_type": "generic",
  "root_cause_zh": "WriteHeader 被调用多次，或在 WriteHeader 之前调用了 Write。只有第一个状态码会被发送。",
  "versions": [
    {
      "version": "1.18",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.21",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Hides a real bug; the wrong status code may be sent to clients.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Does not fix the underlying control flow.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "if !wroteHeader { w.WriteHeader(http.StatusOK); wroteHeader = true }\njson.NewEncoder(w).Encode(v)",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.88,
      "how": "Return early after writing an error status; never write body after WriteHeader without checking.",
      "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": "2024-06-11",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}