go-redis/redis · error

redis.Scan(non-pointer %T)

Error message

redis.Scan(non-pointer %T)

What it means

Error "redis.Scan(non-pointer %T)" thrown in go-redis/redis.

Source

Thrown at internal/hscan/hscan.go:60

		reflect.Ptr:           decodeUnsupported,
		reflect.Slice:         decodeSlice,
		reflect.String:        decodeString,
		reflect.Struct:        decodeUnsupported,
		reflect.UnsafePointer: decodeUnsupported,
	}

	// 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")

View on GitHub (pinned to 36d97525cd)

Solutions

  1. Pass a pointer to the destination struct to Scan (e.g. cmd.Scan(&dst))
  2. Allocate the struct first and pass its address

When it happens

Trigger: Thrown at internal/hscan/hscan.go:60 when the library encounters an invalid state.

Common situations: Wrap Scan in a helper taking interface{} and reflect-check pointer-ness at the boundary.


AI-assisted analysis of go-redis/redis@36d97525cd (2026-08-06). Data as JSON: /data/errors/d86430a366989074.json. Report an issue: GitHub.