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

Method ReadLine

internal/proto/reader.go:260–290  ·  view source on GitHub ↗

ReadLine Return a valid reply, it will check the protocol or redis error, and discard the attribute type.

()

Source from the content-addressed store, hash-verified

258// ReadLine Return a valid reply, it will check the protocol or redis error,
259// and discard the attribute type.
260func (r *Reader) ReadLine() ([]byte, error) {
261 line, err := r.readLine()
262 if err != nil {
263 return nil, err
264 }
265 switch line[0] {
266 case RespError:
267 return nil, ParseErrorReply(line)
268 case RespNil:
269 return nil, Nil
270 case RespBlobError:
271 var blobErr string
272 blobErr, err = r.readStringReply(line)
273 if err == nil {
274 err = parseTypedRedisError(blobErr)
275 }
276 return nil, err
277 case RespAttr:
278 if err = r.Discard(line); err != nil {
279 return nil, err
280 }
281 return r.ReadLine()
282 }
283
284 // Compatible with RESP2
285 if IsNilReply(line) {
286 return nil, Nil
287 }
288
289 return line, nil
290}
291
292// readLine returns an error if:
293// - there is a pending read error;

Callers 12

TestReader_ReadLineFunction · 0.95
ReadReplyMethod · 0.95
ReadIntMethod · 0.95
ReadUintMethod · 0.95
ReadFloatMethod · 0.95
ReadStringIntoMethod · 0.95
ReadStringMethod · 0.95
ReadSliceMethod · 0.95
ReadArrayLenMethod · 0.95
ReadMapLenMethod · 0.95
txPipelineReadQueuedMethod · 0.80
txPipelineReadQueuedMethod · 0.80

Calls 6

readLineMethod · 0.95
readStringReplyMethod · 0.95
DiscardMethod · 0.95
ParseErrorReplyFunction · 0.85
parseTypedRedisErrorFunction · 0.85
IsNilReplyFunction · 0.85

Tested by 1

TestReader_ReadLineFunction · 0.76