func (b *Buffer) Read(d []byte) (int, error) {
	b.lock.Lock()
	defer b.lock.Unlock()

	if b.closed {
		return 0, errors.New("attempt to read from closed buffer")
	}

	if uint64(len(b.contents)) <= b.readCursor {
		return 0, io.EOF
	}

	n := copy(d, b.contents[b.readCursor:])
	b.readCursor += uint64(n)

	return n, nil
}
func (b *Buffer) Read(d []byte) (int, error) {
	b.lock.Lock()
	defer b.lock.Unlock()

	if b.closed {
		return 0, errors.New("attempt to read from closed buffer")
	}

	if uint64(len(b.contents)) <= b.readCursor {
		return 0, io.EOF
	}

	n := copy(d, b.contents[b.readCursor:])
	b.readCursor += uint64(n)

	return n, nil
}
func ( b * Buffer ) Read ( d [ ] byte ) ( int , error ) { b . lock . Lock ( ) defer b . lock . Unlock ( ) if b . closed { return 0 , errors . New ( " " ) } if uint64 ( len ( b . contents ) ) <= b . readCursor { return 0 , io . EOF } n := copy ( d , b . contents [ b . readCursor : ] ) b . readCursor += uint64 ( n ) return n , nil }
/*
Read implements the io.Reader interface. It advances the
cursor as it reads.

Returns an error if called after Close.
*/
/ * Read implements the io . Reader interface . It advances the cursor as it reads .