Documentation
¶
Overview ¶
Package buffer implements a memory buffer with a limited capacity that can overflow into a file on disk.
Example:
var r io.Reader = … b := buffer.Buffer{Capacity: 10<<20} defer b.Cleanup() if _, err := io.Copy(b, r); err != nil { log.Fatal(err) } var w io.Writer = … if _, err = b.WriteTo(w); err != nil { log.Fatal(err) }
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Buffer ¶
type Buffer struct { // The maximum number of bytes that will be buffered in memory before // switching to a file. If ≤ 0, all data will be stored on disk. Capacity int // The path of the temporary file that will be used to store overflow. If // this field is "", a path is chosen by ioutil.TempFile when required; the // caller may read this field to find out the name that was chosen. Path string // contains filtered or unexported fields }
A Buffer is a readable and writable buffer that stores data in memory until it exceeds the given capacity in bytes, and thereafter switches to using a temporary file on disk.
func (*Buffer) Cleanup ¶
func (b *Buffer) Cleanup()
Cleanup cleans up the overflow file created by the buffer, if it exists. The caller should either invoke this method, or take responsibility for cleaning up the file directly by reading the Path field.
Click to show internal directories.
Click to hide internal directories.