v0.1.9 Latest Latest

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

Go to latest
Published: Sep 22, 2015 License: BSD-2-Clause, MIT Imports: 4 Imported by: 0




View Source
const (
	StdWriterPrefixLen = 8
	StdWriterFdIndex   = 0
	StdWriterSizeIndex = 4


View Source
var ErrInvalidStdHeader = errors.New("Unrecognized input header")


func StdCopy

func StdCopy(dstout, dsterr io.Writer, src io.Reader) (written int64, err 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`.


type StdType

type StdType [StdWriterPrefixLen]byte
var (
	Stdin  StdType = StdType{0: 0}
	Stdout StdType = StdType{0: 1}
	Stderr StdType = StdType{0: 2}

type StdWriter

type StdWriter struct {
	// contains filtered or unexported fields

func NewStdWriter

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

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 (*StdWriter) Write

func (w *StdWriter) Write(buf []byte) (n int, err error)

Jump to

Keyboard shortcuts

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