{
  "id": "go/too-many-return-values",
  "signature": "too many return values\n\thave (T, error)\n\twant (T)",
  "signature_zh": "返回值过多\n\t有 (T, error)\n\t想要 (T)",
  "regex": "too many return values\\s+have \\(\\w+, error\\)\\s+want \\(\\w+\\)",
  "domain": "go",
  "category": "compile_error",
  "subcategory": null,
  "root_cause": "A function expecting a single return value is being assigned or used where a multi-return function is called, often due to mismatched function signatures or missing error handling.",
  "root_cause_type": "generic",
  "root_cause_zh": "期望单个返回值的函数被赋值或用于调用多返回值函数的位置，通常是由于函数签名不匹配或缺少错误处理。",
  "versions": [
    {
      "version": "go1.20",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "go1.21",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "go1.22",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Adding an underscore to ignore the error: val, _ := someFunc()",
      "why_fails": "This only works if the caller expects two values; if the caller expects one, the compile error persists.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "Changing the function signature to remove the error return",
      "why_fails": "Modifying the library function breaks its contract and may cause other compilation errors.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "Using a type assertion on the result",
      "why_fails": "Type assertion cannot reduce the number of return values; it only works on interfaces.",
      "fail_rate": 0.98,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Assign both return values to variables and handle the error: val, err := someFunc(); if err != nil { ... }",
      "success_rate": 0.95,
      "how": "Assign both return values to variables and handle the error: val, err := someFunc(); if err != nil { ... }",
      "condition": "",
      "sources": []
    },
    {
      "action": "If the function should return only one value, wrap it in a helper: func wrapper() T { val, _ := someFunc(); return val }",
      "success_rate": 0.85,
      "how": "If the function should return only one value, wrap it in a helper: func wrapper() T { val, _ := someFunc(); return val }",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Assign both return values to variables and handle the error: val, err := someFunc(); if err != nil { ... }",
    "If the function should return only one value, wrap it in a helper: func wrapper() T { val, _ := someFunc(); return val }"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://go.dev/ref/spec#Function_types",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.88,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2023-06-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}