type pipe … type pipeBuffer … // setBuffer initializes the pipe buffer. // It has no effect if the pipe is already closed. func (p *pipe) setBuffer(b pipeBuffer) { … } func (p *pipe) Len() int { … } // Read waits until data is available and copies bytes // from the buffer into p. func (p *pipe) Read(d []byte) (n int, err error) { … } var errClosedPipeWrite … var errUninitializedPipeWrite … // Write copies bytes from p into the buffer and wakes a reader. // It is an error to write more data than the buffer can hold. func (p *pipe) Write(d []byte) (n int, err error) { … } // CloseWithError causes the next Read (waking up a current blocked // Read if needed) to return the provided err after all data has been // read. // // The error must be non-nil. func (p *pipe) CloseWithError(err error) { … } // BreakWithError causes the next Read (waking up a current blocked // Read if needed) to return the provided err immediately, without // waiting for unread data. func (p *pipe) BreakWithError(err error) { … } // closeWithErrorAndCode is like CloseWithError but also sets some code to run // in the caller's goroutine before returning the error. func (p *pipe) closeWithErrorAndCode(err error, fn func()) { … } func (p *pipe) closeWithError(dst *error, err error, fn func()) { … } // requires p.mu be held. func (p *pipe) closeDoneLocked() { … } // Err returns the error (if any) first set by BreakWithError or CloseWithError. func (p *pipe) Err() error { … } // Done returns a channel which is closed if and when this pipe is closed // with CloseWithError. func (p *pipe) Done() <-chan struct{ … }