package chunkreader
Import Path
github.com/jackc/chunkreader/v2 (on go.dev)
Dependency Relation
imports one package, and imported by 2 packages
Involved Source Files
Package chunkreader provides an io.Reader wrapper that minimizes IO reads and memory allocations.
Package-Level Type Names (total 2, both are exported)
ChunkReader is a io.Reader wrapper that minimizes IO reads and memory allocations. It allocates memory in chunks and
will read as much as will fit in the current buffer in a single call regardless of how large a read is actually
requested. The memory returned via Next is owned by the caller. This avoids the need for an additional copy.
The downside of this approach is that a large buffer can be pinned in memory even if only a small slice is
referenced. For example, an entire 4096 byte block could be pinned in memory by even a 1 byte slice. In these rare
cases it would be advantageous to copy the bytes to another slice.
buf []byte
config Config
r io.Reader
// buf read position and write position
// buf read position and write position
Next returns buf filled with the next n bytes. The caller gains ownership of buf. It is not necessary to make a copy
of buf. If an error occurs, buf will be nil.
(*T) appendAtLeast(fillLen int) error
(*T) copyBufContents(dest []byte)
(*T) newBuf(size int) []byte
*T : github.com/jackc/pgproto3/v2.ChunkReader
func New(r io.Reader) *ChunkReader
func NewConfig(r io.Reader, config Config) (*ChunkReader, error)
Config contains configuration parameters for ChunkReader.
// Minimum buffer length
func NewConfig(r io.Reader, config Config) (*ChunkReader, error)
Package-Level Functions (total 2, both are exported)
New creates and returns a new ChunkReader for r with default configuration.
NewConfig creates and a new ChunkReader for r configured by config.
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |