iox

package module
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2026 License: Apache-2.0 Imports: 3 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Copy

func Copy(dst io.Writer, src io.Reader) (written int64, err error)

Copy 类似于 io.Copy, 但内部使用 bytebufferpool 来获取临时缓冲区, 以减少内存分配. 这在需要高性能、高并发拷贝大量数据的场景下非常有用.

func CopyBuffer

func CopyBuffer(dst io.Writer, src io.Reader, buf []byte) (written int64, err error)

CopyBuffer 类似于 io.CopyBuffer, 但在需要时会使用 bytebufferpool 来分配缓冲区. 如果 buf 为 nil, 将从池中获取一个; 如果 buf 长度为0, 会导致 panic. 如果 src 实现了 io.WriterTo 或 dst 实现了 io.ReaderFrom, 将不会使用 buf.

func CopyN

func CopyN(dst io.Writer, src io.Reader, n int64) (written int64, err error)

CopyN 从 src 拷贝 n 字节数据到 dst (或在遇到错误时提前停止). 它返回拷贝的字节数和拷贝时遇到的第一个错误. 仅当 err == nil 时, written == n 才会成立.

此实现利用了池化的 copyb.Copy 和标准的 io.LimitReader, 以实现高性能.

func ReadAll deprecated

func ReadAll(r io.Reader) ([]byte, error)

ReadAll reads from r until EOF.

Deprecated: use io.ReadAll instead.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL