Skip to content

Commit cbd0f3d

Browse files
committed
修复:reader ReadLine() 可能读取不全问题
1 parent 9340a5e commit cbd0f3d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

reader.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package diskqueue
22

33
import (
44
"bufio"
5+
"bytes"
56
"encoding/json"
67
"errors"
78
"fmt"
@@ -33,10 +34,11 @@ func (r *reader) read() (int64, int64, []byte, error) {
3334
}
3435

3536
// read a line
36-
data, _, err := r.reader.ReadLine()
37+
data, err := r.reader.ReadBytes('\n')
3738
if err != nil {
3839
return r.index, r.offset, nil, err
3940
}
41+
data = bytes.TrimRight(data, "\n")
4042

4143
r.offset += int64(len(data)) + 1
4244
return r.index, r.offset, data, err

0 commit comments

Comments
 (0)