Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History

README.md

Outline

goutils/io

IO utilities for copying data with context support and buffer pooling.

Overview

The io package provides enhanced IO operations including context-aware copying.

API Reference

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

Usage

// Basic copy
ioutils.CopyClose(resp.Body, out, 32*1024)

// Context-aware copy
ioutils.CopyCloseWithContext(ctx, w, upstream.Body, 8*1024)

Features

  • Uses 32KB default buffer
  • Supports size hints for optimal allocation (optional)
  • Uses synk.GetSizedBytesPool for buffer pooling to reduce GC pressure
  • HTTP flusher support for streaming responses only (text/event-stream or chunked responses without a Content-Length)
  • Automatic cleanup on context cancellation
Morty Proxy This is a proxified and sanitized view of the page, visit original site.