Documentation ¶
Index ¶
- Constants
- Variables
- type Buffer
- func (b *Buffer) Cap() int
- func (b *Buffer) ChangeTempDir(dir string) error
- func (b *Buffer) EnableEncryption() error
- func (b *Buffer) Len() int
- func (b *Buffer) Next(n int) []byte
- func (b *Buffer) Read(data []byte) (n int, err error)
- func (b *Buffer) ReadByte() (byte, error)
- func (b *Buffer) ReadFrom(r io.Reader) (int64, error)
- func (b *Buffer) Reset()
- func (b *Buffer) Write(data []byte) (n int, err error)
- func (b *Buffer) WriteByte(c byte) error
- func (b *Buffer) WriteRune(r rune) (n int, err error)
- func (b *Buffer) WriteString(s string) (n int, err error)
- func (b *Buffer) WriteTo(w io.Writer) (int64, error)
Constants ¶
const ( // DefaultMaxMemorySize is used when Buffer is created with NewBuffer() or NewBufferString() DefaultMaxMemorySize = 2 << 20 // 2 MB )
Variables ¶
var ( // ErrBufferFinished is used when Buffer.Write() method is called after Buffer.Read() ErrBufferFinished = errors.New("buffer is finished") )
Functions ¶
This section is empty.
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer is a buffer which can store data on a disk. It isn't thread-safe!
func NewBuffer ¶
NewBuffer creates a new Buffer with DefaultMaxMemorySize and calls Write(buf). If an error occurred, it panics
func NewBufferString ¶
NewBufferString calls NewBuffer([]byte(s))
func NewBufferWithMaxMemorySize ¶
NewBufferWithMaxMemorySize creates a new Buffer with passed maxInMemorySize
func (*Buffer) ChangeTempDir ¶ added in v0.2.0
ChangeTempDir changes directory for temp files
func (*Buffer) EnableEncryption ¶ added in v0.3.0
EnableEncryption enables encryption and generates an encryption key
func (*Buffer) Next ¶
Next returns a slice containing the next n bytes from the buffer. If an error occurred, it panics
func (*Buffer) Read ¶
Read reads data from bytes.Buffer or from a file. A temp file is deleted when Read() encounter n == 0
func (*Buffer) Write ¶
Write writes data into bytes.Buffer while size of the Buffer is less than maxInMemorySize, when size of Buffer is equal to maxInMemorySize, Write creates a temporary file and writes remaining data into this one. Write returns ErrBufferFinished after the call of Buffer.Read(), Buffer.ReadByte() or Buffer.Next()
func (*Buffer) WriteRune ¶
WriteRune writes a rune.
It uses bytes.Buffer and Buffer.Write underhood.
func (*Buffer) WriteString ¶
WriteString writes a string