Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // Stdin represents standard input stream type. Stdin = StdType{0: 0} // Stdout represents standard output stream type. Stdout = StdType{0: 1} // Stderr represents standard error steam type. Stderr = StdType{0: 2} )
Functions ¶
func StdCopy ¶
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 [stdWriterPrefixLen]byte
StdType prefixes type and length to standard stream.
type StdWriter ¶
StdWriter is wrapper of io.Writer with extra customized info.
func NewStdWriter ¶
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.