File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed
Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -103,20 +103,20 @@ func (li *lineWriter) Write(ogb []byte) (int, error) {
103103 }
104104 li .b .Write (ogb ) // bytes.Buffer is guaranteed, read it!
105105
106+ var n int
106107 for {
107- b := li . b . Bytes ()
108- i := bytes . IndexByte ( b , '\n' )
109- if i < 0 {
110- break // no more newlines in buffer
108+ // read the line and advance buffer past it
109+ l , err := li . b . ReadBytes ( '\n' )
110+ if err != nil {
111+ break // no more newlines in buffer (see ReadBytes contract)
111112 }
112113
113- // write in this line and advance buffer past it
114- l := b [:i + 1 ]
114+ // write in the line
115115 ns , err := li .w .Write (l )
116+ n += ns
116117 if err != nil {
117- return ns , err
118+ return n , err
118119 }
119- li .b .Next (len (l ))
120120 }
121121
122122 // technically we wrote all the bytes, so make things appear normal
You can’t perform that action at this time.
0 commit comments