{
  "id": "go/struct-comparison-not-allowed",
  "signature": "cannot compare x (variable of type struct { ... }) with y (variable of type struct { ... })",
  "signature_zh": "无法比较 x（类型为 struct { ... } 的变量）和 y（类型为 struct { ... } 的变量）",
  "regex": "cannot compare .+ \\(variable of type struct \\{.*\\}\\) with .+ \\(variable of type struct \\{.*\\}\\)",
  "domain": "go",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "Structs containing fields that are not comparable (e.g., slices, maps, functions) cannot be directly compared with == or !=.",
  "root_cause_type": "generic",
  "root_cause_zh": "包含不可比较字段（如切片、映射、函数）的结构体不能直接使用 == 或 != 进行比较。",
  "versions": [
    {
      "version": "Go 1.20",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Go 1.21",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Go 1.22",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Go does not support operator overloading; you cannot define a custom == method.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "reflect.DeepEqual works but may have performance overhead and does not handle unexported fields in some cases.",
      "fail_rate": 0.4,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Interface comparison still requires underlying values to be comparable; same error will occur.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Use reflect.DeepEqual() for deep comparison: if reflect.DeepEqual(a, b) { ... }",
      "success_rate": 0.85,
      "how": "Use reflect.DeepEqual() for deep comparison: if reflect.DeepEqual(a, b) { ... }",
      "condition": "",
      "sources": []
    },
    {
      "action": "Implement a custom comparison function that manually compares each comparable field and uses reflect.DeepEqual for incomparable ones.",
      "success_rate": 0.8,
      "how": "Implement a custom comparison function that manually compares each comparable field and uses reflect.DeepEqual for incomparable ones.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Redesign the struct to avoid incomparable fields (e.g., replace slices with arrays of fixed size).",
      "success_rate": 0.75,
      "how": "Redesign the struct to avoid incomparable fields (e.g., replace slices with arrays of fixed size).",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Use reflect.DeepEqual() for deep comparison: if reflect.DeepEqual(a, b) { ... }",
    "Implement a custom comparison function that manually compares each comparable field and uses reflect.DeepEqual for incomparable ones.",
    "Redesign the struct to avoid incomparable fields (e.g., replace slices with arrays of fixed size)."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://go.dev/ref/spec#Comparison_operators",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.87,
  "fix_success_rate": 0.88,
  "resolvable": "true",
  "first_seen": "2023-04-10",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}