{"record":{"id":"b3b203d4ad54f794","repo":"go-delve/delve","slug":"can-not-convert-value-of-type-s-to-s-v","errorCode":null,"errorMessage":"can not convert value of type %s to %s: %v","messagePattern":"can not convert value of type (.+?) to (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/variables.go","lineNumber":1516,"sourceCode":"// interface or a pointer shaped variable (map, channel, pointer or struct\n// containing a single pointer)\nfunc convertToEface(srcv, dstv *Variable) error {\n\tif dstv.RealType.String() != \"interface {}\" {\n\t\treturn &typeConvErr{srcv.DwarfType, dstv.RealType}\n\t}\n\tif _, isiface := srcv.RealType.(*godwarf.InterfaceType); isiface {\n\t\t// iface -> eface conversion\n\t\t_type, data, _ := srcv.readInterface()\n\t\tif srcv.Unreadable != nil {\n\t\t\treturn srcv.Unreadable\n\t\t}\n\t\t_type = _type.maybeDereference()\n\t\tdstv.writeEmptyInterface(_type.Addr, data)\n\t\treturn nil\n\t}\n\ttypeAddr, direct, runtimeTypeFound, err := dwarfToRuntimeType(srcv.bi, srcv.mem, srcv.RealType)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"can not convert value of type %s to %s: %v\", srcv.DwarfType.String(), dstv.DwarfType.String(), err)\n\t}\n\tif !runtimeTypeFound || !direct {\n\t\treturn &typeConvErr{srcv.DwarfType, dstv.RealType}\n\t}\n\treturn dstv.writeEmptyInterface(typeAddr, srcv)\n}\n\nfunc readStringInfo(mem MemoryReadWriter, arch *Arch, addr uint64, typ *godwarf.StringType) (uint64, int64, error) {\n\t// string data structure is always two ptrs in size. Addr, followed by len\n\t// https://research.swtch.com/godata\n\n\tmem = cacheMemory(mem, addr, arch.PtrSize()*2)\n\n\tvar strlen int64\n\tvar outaddr uint64\n\tvar err error\n\n\tfor _, field := range typ.StructType.Field {","sourceCodeStart":1498,"sourceCodeEnd":1534,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/variables.go#L1498-L1534","documentation":"`convertToEface` failed while converting a variable into an `interface {}`: either the DWARF type could not be mapped to a Go runtime type (`dwarfToRuntimeType` returned an error) or the runtime type was not found/direct. The low-level cause is wrapped into this message.","triggerScenarios":"Assigning or converting a value into an eface variable during evaluation (Delve's internal conversion used by `set` and certain expression evaluations) when `srcv.RealType` has no direct runtime-type equivalent, or when reading the runtime type structures from memory fails.","commonSituations":"Using `set` on interface variables with values whose DWARF types cannot be resolved to runtime types (e.g. C types via cgo, types from cgo-generated code); debugging stripped or oddly compiled binaries where the types link section is incomplete.","solutions":["Check the wrapped cause (%v) for the underlying runtime-type lookup failure.","Convert to a concrete Go type first, or set the field directly rather than through an interface.","Ensure the binary was built without stripping DWARF/types sections (`-w`, `-s` flags removed).","For cgo values, avoid interface conversion in the debugger; inspect fields individually."],"exampleFix":"// before (delve cli)\nset iface = cStructValue // can not convert value of type C.struct_foo to interface {}\n// after\nset ifaceField.intField = cStructValue.intField","handlingStrategy":"validation","validationCode":"// Only assign values whose types are normal Go types to interfaces:\n// (dlv) set iface = concreteGoValue   // OK\n// (dlv) set iface = cgoValue          // may fail; use field-wise assignment instead","typeGuard":null,"tryCatchPattern":"err := dstv.convertToEface(_type, srcv)\nif err != nil {\n    var tc *typeConvErr\n    if errors.As(err, &tc) || strings.Contains(err.Error(), \"can not convert value of type\") {\n        // fall back to assigning concrete fields\n    }\n}","preventionTips":["Avoid converting cgo/C types to interfaces in the debugger.","Build with DWARF and type info intact (no -w/-s).","Set concrete fields directly instead of whole-interface assignment."],"tags":["debugger","go","type-conversion","interface"],"backgroundTag":"eface-conversion-failed","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}