ReadLine Return a valid reply, it will check the protocol or redis error, and discard the attribute type.
()
| 258 | // ReadLine Return a valid reply, it will check the protocol or redis error, |
| 259 | // and discard the attribute type. |
| 260 | func (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; |