type buffer … type element … // newBuffer returns an empty buffer that is not closed. func newBuffer() *buffer { … } // write makes buf available for Read to receive. // buf must not be modified after the call to write. func (b *buffer) write(buf []byte) { … } // eof closes the buffer. Reads from the buffer once all // the data has been consumed will receive io.EOF. func (b *buffer) eof() { … } // Read reads data from the internal buffer in buf. Reads will block // if no data is available, or until the buffer is closed. func (b *buffer) Read(buf []byte) (n int, err error) { … }