contextio

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package contextio provides io.Writer and io.Reader that stop accepting/providing data when an attached context is canceled.

AJ: I want to minimize 3rd party dependencies on my own go-aj packages This was taken from https://github.com/dolmen-go/contextio as is.

Package contextio provides io.Writer and io.Reader that stop accepting/providing data when an attached context is canceled.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCloser

func NewCloser(ctx context.Context, c io.Closer) io.Closer

NewCloser wraps an io.Reader to handle context cancellation.

Context state is checked BEFORE any Close.

func NewReader

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

NewReader wraps an io.Reader to handle context cancellation.

Context state is checked BEFORE every Read.

func NewWriter

func NewWriter(ctx context.Context, w io.Writer) io.Writer

NewWriter wraps an io.Writer to handle context cancellation.

Context state is checked BEFORE every Write.

The returned Writer also implements io.ReaderFrom to allow io.Copy to select the best strategy while still checking the context state before every chunk transfer.

Types

This section is empty.

Jump to

Keyboard shortcuts

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