{"id":"df365ef3b9a03423","repo":"go-redis/redis","slug":"redis-scan-non-struct-t","errorCode":null,"errorMessage":"redis.Scan(non-struct %T)","messagePattern":"redis\\.Scan\\(non-struct %T\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/hscan/hscan.go","lineNumber":65,"sourceCode":"\t}\n\n\t// Global map of struct field specs that is populated once for every new\n\t// struct type that is scanned. This caches the field types and the corresponding\n\t// decoder functions to avoid iterating through struct fields on subsequent scans.\n\tglobalStructMap = newStructMap()\n)\n\nfunc Struct(dst interface{}) (StructValue, error) {\n\tv := reflect.ValueOf(dst)\n\n\t// The destination to scan into should be a struct pointer.\n\tif v.Kind() != reflect.Ptr || v.IsNil() {\n\t\treturn StructValue{}, fmt.Errorf(\"redis.Scan(non-pointer %T)\", dst)\n\t}\n\n\tv = v.Elem()\n\tif v.Kind() != reflect.Struct {\n\t\treturn StructValue{}, fmt.Errorf(\"redis.Scan(non-struct %T)\", dst)\n\t}\n\n\treturn StructValue{\n\t\tspec:  globalStructMap.get(v.Type()),\n\t\tvalue: v,\n\t}, nil\n}\n\n// Scan scans the results from a key-value Redis map result set to a destination struct.\n// The Redis keys are matched to the struct's field with the `redis` tag.\nfunc Scan(dst interface{}, keys []interface{}, vals []interface{}) error {\n\tif len(keys) != len(vals) {\n\t\treturn errors.New(\"args should have the same number of keys and vals\")\n\t}\n\n\tstrct, err := Struct(dst)\n\tif err != nil {\n\t\treturn err","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/go-redis/redis/blob/36d97525cd8076aed67cddf54778e9ea84550929/internal/hscan/hscan.go#L47-L83","documentation":"Error \"redis.Scan(non-struct %T)\" thrown in go-redis/redis.","triggerScenarios":"Thrown at internal/hscan/hscan.go:65 when the library encounters an invalid state.","commonSituations":"Document the destination type requirement at the call site and validate with reflection in shared helpers.","solutions":["Pass a pointer to a struct, not a map/slice/scalar, to Scan","For non-struct destinations use cmd.Result() and parse manually"],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"36d97525cd8076aed67cddf54778e9ea84550929","analyzedAt":"2026-08-06T01:08:27.376Z","schemaVersion":2}