Skip to content

Commit

Permalink
Merge pull request #3 from ldez/fix/error-message
Browse files Browse the repository at this point in the history
fix: error message.
  • Loading branch information
thrawn01 committed May 9, 2022
2 parents 565402c + 48671c5 commit a4ef56f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ _testmain.go
*.exe
*.test
*.prof

vendor/
10 changes: 5 additions & 5 deletions buffer.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// package multibuf implements buffer optimized for streaming large chunks of data,
// Package multibuf implements buffer optimized for streaming large chunks of data,
// multiple reads and optional partial buffering to disk.
package multibuf

Expand Down Expand Up @@ -157,9 +157,10 @@ type MaxSizeReachedError struct {
}

func (e *MaxSizeReachedError) Error() string {
return fmt.Sprintf("Maximum size %d was reached", e)
return fmt.Sprintf("Maximum size %d was reached", e.MaxSize)
}

// Default sizes
const (
DefaultMemBytes = 1048576
DefaultMaxBytes = -1
Expand Down Expand Up @@ -298,7 +299,6 @@ const (

type writerOnce struct {
o options
err error
state int
mem *bytes.Buffer
file *os.File
Expand Down Expand Up @@ -357,7 +357,7 @@ func (w *writerOnce) write(p []byte) (int, error) {
}
// we can't write to memory any more, switch to file
if err := w.initFile(); err != nil {
return int(writeToMem), err
return writeToMem, err
}
w.state = writerFile
wrote, err := w.file.Write(p[writeToMem:])
Expand Down Expand Up @@ -406,7 +406,7 @@ func (w *writerOnce) Reader() (MultiReader, error) {
w.mem = nil
return newBuf(w.total, w.cleanupFn, br, fr), nil
}
return nil, fmt.Errorf("unsupported state: %d\n", w.state)
return nil, fmt.Errorf("unsupported state: %d", w.state)
}

const tempFilePrefix = "temp-multibuf-"
1 change: 1 addition & 0 deletions buffer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ func (s *BufferSuite) TestSeekFirst(c *C) {
tlen := int64(1057576)
r, hash := createReaderOfSize(tlen)
bb, err := New(r)
c.Assert(err, IsNil)

l, err := bb.Size()
c.Assert(err, IsNil)
Expand Down

0 comments on commit a4ef56f

Please sign in to comment.