|
1 | | -// package multibuf implements buffer optimized for streaming large chunks of data, |
| 1 | +// Package multibuf implements buffer optimized for streaming large chunks of data, |
2 | 2 | // multiple reads and optional partial buffering to disk. |
3 | 3 | package multibuf |
4 | 4 |
|
@@ -157,9 +157,10 @@ type MaxSizeReachedError struct { |
157 | 157 | } |
158 | 158 |
|
159 | 159 | func (e *MaxSizeReachedError) Error() string { |
160 | | - return fmt.Sprintf("Maximum size %d was reached", e) |
| 160 | + return fmt.Sprintf("Maximum size %d was reached", e.MaxSize) |
161 | 161 | } |
162 | 162 |
|
| 163 | +// Default sizes |
163 | 164 | const ( |
164 | 165 | DefaultMemBytes = 1048576 |
165 | 166 | DefaultMaxBytes = -1 |
@@ -298,7 +299,6 @@ const ( |
298 | 299 |
|
299 | 300 | type writerOnce struct { |
300 | 301 | o options |
301 | | - err error |
302 | 302 | state int |
303 | 303 | mem *bytes.Buffer |
304 | 304 | file *os.File |
@@ -357,7 +357,7 @@ func (w *writerOnce) write(p []byte) (int, error) { |
357 | 357 | } |
358 | 358 | // we can't write to memory any more, switch to file |
359 | 359 | if err := w.initFile(); err != nil { |
360 | | - return int(writeToMem), err |
| 360 | + return writeToMem, err |
361 | 361 | } |
362 | 362 | w.state = writerFile |
363 | 363 | wrote, err := w.file.Write(p[writeToMem:]) |
@@ -406,7 +406,7 @@ func (w *writerOnce) Reader() (MultiReader, error) { |
406 | 406 | w.mem = nil |
407 | 407 | return newBuf(w.total, w.cleanupFn, br, fr), nil |
408 | 408 | } |
409 | | - return nil, fmt.Errorf("unsupported state: %d\n", w.state) |
| 409 | + return nil, fmt.Errorf("unsupported state: %d", w.state) |
410 | 410 | } |
411 | 411 |
|
412 | 412 | const tempFilePrefix = "temp-multibuf-" |
0 commit comments