| 514 | } |
| 515 | |
| 516 | func (r *Reader) ReadFloat() (float64, error) { |
| 517 | line, err := r.ReadLine() |
| 518 | if err != nil { |
| 519 | return 0, err |
| 520 | } |
| 521 | switch line[0] { |
| 522 | case RespFloat: |
| 523 | return r.readFloat(line) |
| 524 | case RespStatus: |
| 525 | return strconv.ParseFloat(util.BytesToString(line[1:]), 64) |
| 526 | case RespString: |
| 527 | s, err := r.readStringReply(line) |
| 528 | if err != nil { |
| 529 | return 0, err |
| 530 | } |
| 531 | return strconv.ParseFloat(s, 64) |
| 532 | } |
| 533 | return 0, fmt.Errorf("redis: can't parse float reply: %.100q", line) |
| 534 | } |
| 535 | |
| 536 | // ReadStringInto reads a string-typed reply directly into buf, avoiding the |
| 537 | // per-call allocation that ReadString incurs. It returns the number of bytes |