stdcopy

package
v1.52.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2025 License: Apache-2.0 Imports: 4 Imported by: 24

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StdCopy

func StdCopy(destOut, destErr io.Writer, multiplexedSource io.Reader) (written int64, _ error)

StdCopy is a modified version of io.Copy to de-multiplex messages from "multiplexedSource" and copy them to destination streams "destOut" and "destErr".

StdCopy demultiplexes "multiplexedSource", assuming that it contains two streams, previously multiplexed using a writer created with [NewStdWriter].

As it reads from "multiplexedSource", StdCopy writes Stdout messages to "destOut", and Stderr message to "destErr]. For backward-compatibility, Stdin messages are output to "destOut". The Systemerr stream provides errors produced by the daemon. It is returned as an error, and terminates processing the stream.

StdCopy it reads until it hits io.EOF on "multiplexedSource", after which it returns a nil error. In other words: any error returned indicates a real underlying error, which may be when an unknown StdType stream is received.

The "written" return holds the total number of bytes written to "destOut" and "destErr" combined.

Types

type StdType

type StdType byte

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

const (
	Stdin     StdType = 0 // Stdin represents standard input stream. It is present for completeness and should NOT be used. When reading the stream with [StdCopy] it is output on [Stdout].
	Stdout    StdType = 1 // Stdout represents standard output stream.
	Stderr    StdType = 2 // Stderr represents standard error steam.
	Systemerr StdType = 3 // Systemerr represents errors originating from the system. When reading the stream with [StdCopy] it is returned as an error.
)

Jump to

Keyboard shortcuts

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