{"record":{"id":"b0de6e360c11ce1c","repo":"go-delve/delve","slug":"structure-too-deep-for-comparison","errorCode":null,"errorMessage":"structure too deep for comparison","messagePattern":"structure too deep for comparison","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/eval.go","lineNumber":2672,"sourceCode":"\t\tcase token.NEQ:\n\t\t\treturn !xv.isNil(), nil\n\t\t}\n\t}\n\n\tswitch xv.Kind {\n\tcase reflect.Ptr:\n\t\teql = xv.Children[0].Addr == yv.Children[0].Addr\n\tcase reflect.Array:\n\t\tif int64(len(xv.Children)) != xv.Len || int64(len(yv.Children)) != yv.Len {\n\t\t\treturn false, errors.New(\"array too long for comparison\")\n\t\t}\n\t\teql, err = equalChildren(xv, yv, true)\n\tcase reflect.Struct:\n\t\tif len(xv.Children) != len(yv.Children) {\n\t\t\treturn false, nil\n\t\t}\n\t\tif int64(len(xv.Children)) != xv.Len || int64(len(yv.Children)) != yv.Len {\n\t\t\treturn false, errors.New(\"structure too deep for comparison\")\n\t\t}\n\t\teql, err = equalChildren(xv, yv, false)\n\tcase reflect.Slice, reflect.Map, reflect.Func, reflect.Chan:\n\t\treturn false, fmt.Errorf(\"can not compare %s variables\", xv.Kind.String())\n\tcase reflect.Interface:\n\t\tif xv.Children[0].RealType.String() != yv.Children[0].RealType.String() {\n\t\t\teql = false\n\t\t} else {\n\t\t\teql, err = compareOp(token.EQL, &xv.Children[0], &yv.Children[0])\n\t\t}\n\tdefault:\n\t\treturn false, fmt.Errorf(\"unimplemented comparison of %s variables\", xv.Kind.String())\n\t}\n\n\tif op == token.NEQ {\n\t\treturn !eql, err\n\t}\n\treturn eql, err","sourceCodeStart":2654,"sourceCodeEnd":2690,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/eval.go#L2654-L2690","documentation":"When comparing two structs, Delve loads all field children of both. If a struct has more fields than the configured limit (MaxStructFields / array-value caps) some fields were not loaded; comparing would silently skip fields, so Delve throws this error. The name is slightly misleading: it is about struct field truncation, not pointer depth.","triggerScenarios":"Evaluating 'print structA == structB' (or !=) where at least one struct has more fields than were loaded (len(Children) != v.Len) due to load limits.","commonSituations":"Comparing large configuration/log structs in the debugger; API clients with restrictive LoadConfig limits evaluating struct equality expressions.","solutions":["Raise the load limits (config max-array-values / max-struct-fields style config in the CLI, or MaxStructFields in LoadConfig) and retry","Compare field-by-field: 'print a.Field1 == b.Field1' etc., which is often more informative anyway","Compare only the fields you care about instead of whole-struct equality","For API clients, increase cfg.MaxStructFields before evaluating the comparison"],"exampleFix":"// before (dlv CLI)\n(dlv) print cfgA == cfgB   // struct with many fields -> error\n\n// after\n(dlv) print cfgA.Name == cfgB.Name && cfgA.Port == cfgB.Port","handlingStrategy":"validation","validationCode":"// before comparing structs in dlv, prefer field-wise comparison for large structs:\n(dlv) print a.Field1 == b.Field1 && a.Field2 == b.Field2","typeGuard":null,"tryCatchPattern":"// RPC client pattern\nval, err := client.EvalVariable(scope, \"sa == sb\", cfg)\nif err != nil && strings.Contains(err.Error(), \"structure too deep for comparison\") {\n    // fall back to per-field evaluation\n    for _, f := range fields {\n        client.EvalVariable(scope, fmt.Sprintf(\"sa.%s == sb.%s\", f, f), cfg)\n    }\n}","preventionTips":["Avoid whole-struct equality for structs with many fields; compare the fields that matter","Raise load limits (MaxStructFields/MaxArrayValues) in LoadConfig for API clients","Remember loaded child count must match the struct's full field count for a valid comparison","Use diffs at the source level (log/breakpoint inspection) instead of expression equality for big structs"],"tags":["go","debugger","struct-comparison","truncation"],"backgroundTag":"struct-truncated-for-comparison","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}