IO utilities for copying data with context support and buffer pooling.
The io package provides enhanced IO operations including context-aware copying.
func CopyCloseWithContext(ctx context.Context, dst io.Writer, src io.Reader, sizeHint int) error
func CopyClose(dst io.Writer, src io.Reader, sizeHint int) error// Basic copy
ioutils.CopyClose(resp.Body, out, 32*1024)
// Context-aware copy
ioutils.CopyCloseWithContext(ctx, w, upstream.Body, 8*1024)- Uses 32KB default buffer
- Supports size hints for optimal allocation (optional)
- Uses
synk.GetSizedBytesPoolfor buffer pooling to reduce GC pressure - HTTP flusher support for streaming responses only (
text/event-streamor chunked responses without aContent-Length) - Automatic cleanup on context cancellation