MCPcopy
hub / github.com/redis/go-redis / ScanSlice

Function ScanSlice

internal/proto/scan.go:129–152  ·  view source on GitHub ↗
(data []string, slice interface{})

Source from the content-addressed store, hash-verified

127}
128
129func ScanSlice(data []string, slice interface{}) error {
130 v := reflect.ValueOf(slice)
131 if !v.IsValid() {
132 return fmt.Errorf("redis: ScanSlice(nil)")
133 }
134 if v.Kind() != reflect.Ptr {
135 return fmt.Errorf("redis: ScanSlice(non-pointer %T)", slice)
136 }
137 v = v.Elem()
138 if v.Kind() != reflect.Slice {
139 return fmt.Errorf("redis: ScanSlice(non-slice %T)", slice)
140 }
141
142 next := makeSliceNextElemFunc(v)
143 for i, s := range data {
144 elem := next()
145 if err := Scan([]byte(s), elem.Addr().Interface()); err != nil {
146 err = fmt.Errorf("redis: ScanSlice index=%d value=%q failed: %w", i, s, err)
147 return err
148 }
149 }
150
151 return nil
152}
153
154func makeSliceNextElemFunc(v reflect.Value) func() reflect.Value {
155 elemType := v.Type().Elem()

Callers 2

ScanSliceMethod · 0.92
scan_test.goFile · 0.92

Calls 4

makeSliceNextElemFuncFunction · 0.85
ScanFunction · 0.70
IsValidMethod · 0.45
AddrMethod · 0.45

Tested by

no test coverage detected