// Write writes data to the wrapped slice if there is enough space available.
// If not, data is written until the wrapped slice has reached its capacity
// and io.EOF is returned.
Write writes data to the wrapped slice if there is enough space available.
If not, data is written until the wrapped slice has reached its capacity
and io.EOF is returned.
// Write writes data to the wrapped slice if there is enough space available . // If not data is written until the wrapped slice has reached its capacity // and io . EOF is returned .
func (b ByteWriter) Write(data []byte) (int, error) {
	start := len(*b.buffer)
	size := len(data)
	capacity := cap(*b.buffer)
	if start+size > capacity {
		size := capacity - start
		*b.buffer = (*b.buffer)[:capacity]
		copy((*b.buffer)[start:], data[:size])
		return size, io.EOF
	}
	*b.buffer = (*b.buffer)[:start+size]
	copy((*b.buffer)[start:], data)
	return size, nil
}
func ( b ByteWriter ) Write ( data [ ] byte ) ( int , error ) { start := len ( * b . buffer ) size := len ( data ) capacity := cap ( * b . buffer ) if start + size > capacity { size := capacity - start * b . buffer = ( * b . buffer ) [ : capacity ] copy ( ( * b . buffer ) [ start : ] , data [ : size ] ) return size , io . EOF } * b . buffer = ( * b . buffer ) [ : start + size ] copy ( ( * b . buffer ) [ start : ] , data ) return size , nil }
Write writes data to the wrapped slice if there is enough space available.
Write writes data to the wrapped slice if there is enough space available .