Help us shape the future of Go! Take the 2026 Go Developer Survey

ctxio

package
v0.1.22 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package ctxio makes a long copy stop with its context.

io.Copy runs to the end of its source whatever happens around it, and a source of many GiB on a slow disk takes minutes. Read through Reader, the copy ends at the next read after a stop.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Reader

func Reader(ctx context.Context, r io.Reader) io.Reader

Reader reads from r for as long as ctx lasts. Once ctx is done, Read returns ctx.Err() and reads nothing, so a copy from it fails with that error at its next read.

The context is asked before every read. A copy reads 32 KiB or more at a time, so the check costs nothing a reader of files would notice.

Types

This section is empty.

Jump to

Keyboard shortcuts

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