stdcopy

package
v1.16.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package stdcopy is derived from Moby's stdcopy implementation.

Source: https://github.com/moby/moby/blob/v28.5.2/pkg/stdcopy/stdcopy.go License: Apache License 2.0 SPDX-License-Identifier: Apache-2.0

Modified to fix lint errors This local copy is vendored to avoid pulling conflicting module variants during dependency resolution in this monorepo.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewStdWriter

func NewStdWriter(w io.Writer, t StdType) io.Writer

NewStdWriter instantiates a new Writer. Everything written to it will be encapsulated using a custom format, and written to the underlying `w` stream. This allows multiple write streams (e.g. stdout and stderr) to be muxed into a single connection. `t` indicates the id of the stream to encapsulate. It can be stdcopy.Stdin, stdcopy.Stdout, stdcopy.Stderr.

func StdCopy

func StdCopy(dstout, dsterr io.Writer, src io.Reader) (written int64, _ error)

StdCopy is a modified version of io.Copy.

StdCopy will demultiplex `src`, assuming that it contains two streams, previously multiplexed together using a StdWriter instance. As it reads from `src`, StdCopy will write to `dstout` and `dsterr`.

StdCopy will read until it hits EOF on `src`. It will then return a nil error. In other words: if `err` is non nil, it indicates a real underlying error.

`written` will hold the total number of bytes written to `dstout` and `dsterr`.

Types

type StdType

type StdType byte

StdType is the type of standard stream a writer can multiplex to.

const (
	// Stdin represents standard input stream type.
	Stdin StdType = iota
	// Stdout represents standard output stream type.
	Stdout
	// Stderr represents standard error steam type.
	Stderr
	// Systemerr represents errors originating from the system that make it
	// into the multiplexed stream.
	Systemerr
)

Jump to

Keyboard shortcuts

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