go-redis/redis · error
redis.Scan(non-struct %T)
Error message
redis.Scan(non-struct %T)
What it means
Error "redis.Scan(non-struct %T)" thrown in go-redis/redis.
Source
Thrown at internal/hscan/hscan.go:65
}
// Global map of struct field specs that is populated once for every new
// struct type that is scanned. This caches the field types and the corresponding
// decoder functions to avoid iterating through struct fields on subsequent scans.
globalStructMap = newStructMap()
)
func Struct(dst interface{}) (StructValue, error) {
v := reflect.ValueOf(dst)
// The destination to scan into should be a struct pointer.
if v.Kind() != reflect.Ptr || v.IsNil() {
return StructValue{}, fmt.Errorf("redis.Scan(non-pointer %T)", dst)
}
v = v.Elem()
if v.Kind() != reflect.Struct {
return StructValue{}, fmt.Errorf("redis.Scan(non-struct %T)", dst)
}
return StructValue{
spec: globalStructMap.get(v.Type()),
value: v,
}, nil
}
// Scan scans the results from a key-value Redis map result set to a destination struct.
// The Redis keys are matched to the struct's field with the `redis` tag.
func Scan(dst interface{}, keys []interface{}, vals []interface{}) error {
if len(keys) != len(vals) {
return errors.New("args should have the same number of keys and vals")
}
strct, err := Struct(dst)
if err != nil {
return errView on GitHub (pinned to 36d97525cd)
Solutions
- Pass a pointer to a struct, not a map/slice/scalar, to Scan
- For non-struct destinations use cmd.Result() and parse manually
When it happens
Trigger: Thrown at internal/hscan/hscan.go:65 when the library encounters an invalid state.
Common situations: Document the destination type requirement at the call site and validate with reflection in shared helpers.
AI-assisted analysis of go-redis/redis@36d97525cd (2026-08-06).
Data as JSON: /data/errors/df365ef3b9a03423.json.
Report an issue: GitHub.