Selaa lähdekoodia

flush when not buffered

Darien Raymond 8 vuotta sitten
vanhempi
commit
743d35c059
1 muutettua tiedostoa jossa 2 lisäystä ja 1 poistoa
  1. 2 1
      common/buf/writer.go

+ 2 - 1
common/buf/writer.go

@@ -67,13 +67,14 @@ func (w *BufferedWriter) Write(b []byte) (int, error) {
 		if err != nil {
 			return totalBytes, err
 		}
-		if w.buffer.IsFull() {
+		if !w.buffered || w.buffer.IsFull() {
 			if err := w.Flush(); err != nil {
 				return totalBytes, err
 			}
 		}
 		b = b[nBytes:]
 	}
+
 	return totalBytes, nil
 }