// Writes up to len(buf) bytes to a file. Returns the number of
// bytes written, or an Error.
324226
func (file *File) Write(buf []byte) (int, error) {
	n, err := file.WriteAt(buf, int64(file.offset))
	if err == nil {
		file.offset += uint64(n)
	}

	return n, err
}
86788
func (r *Response) Write(buf []byte) (int, error) {
	// Some http Handler will call Write directly.
	if !r.wroteHeader.isTrue() {
		if r.status == 0 {
			r.status = 200
		}
		r.WriteHeader(0)
	}
	return r.rw.Write(buf)
}
280040
func (w *FuncWriter) Write(b []byte) (int, error) {
	w.fx(b)
	return len(b), nil
}
376911
func (ctn *Connection) Write(buf []byte) (total int, err error) {
	// make sure all bytes are written
	// Don't worry about the loop, timeout has been set elsewhere
	length := len(buf)
	for total < length {
		var r int
		if err = ctn.updateDeadline(); err != nil {
			break
		}
		r, err = ctn.conn.Write(buf[total:])
		total += r
		if err != nil {
			break
		}
	}

	// If all bytes are written, ignore any potential error
	// The error will bubble up on the next network io if it matters.
	if total == len(buf) {
		return total, nil
	}

	if ctn.node != nil {
		atomic.AddInt64(&ctn.node.stats.ConnectionsFailed, 1)
	}

	ctn.Close()

	return total, errToTimeoutErr(ctn, err)
}
128937
func (enc *Encoder) writeByte(c byte) {
	enc.buf = append(enc.buf, c)
}
1042792
func (c Conn) Write(buf []byte) (n int, err error) {
	if c.writeTimeout > 0 {
		c.SetDeadline(time.Now().Add(c.writeTimeout))
	}
	n, err = c.netConn.Write(buf)
	if c.writeTimeout > 0 {
		c.SetDeadline(time.Time{})
	}
	return
}
44188
func WriteByte(w io.Writer, value byte) error {
	var buf [1]byte
	buf[0] = value
	_, err := w.Write(buf[:])
	return err
}
989649
func (b *Buffer) writebyte(bbyte byte) {
	b.buffer[b.end] = bbyte
	b.end = (b.end + 1) % b.size
	if b.end == b.start {
		b.start = (b.start + 1) % b.size
	}
}
1087960
func (txt *Text) Write(p []byte) (n int, err error) {
	txt.buf = append(txt.buf, p...)
	txt.drawBuf()
	return len(p), nil
}
1289278
func (buf *Buffer) Write(p []byte) (int, error) {
	r := len(buf.buf) + len(p)
	if cap(buf.buf) < r {
		l := r
		for {
			if l > r {
				break
			}
			l *= 2
		}
		buf.grow(l - cap(buf.buf))
	}
	buf.buf = append(buf.buf, p...)
	return len(p), nil
}
190808
func (bufc *bufConn) Write(b []byte) (int, error) {
	return bufc.conn.Write(b)
}
233956
func (w *Writer) Write(p []byte) (n int, err error) {
	return w.buf.Write(p)
}
653546
func (w *ByteWriter) WriteByte(c byte) error {
	p := w.grow(1)
	w.buf[p] = c
	return nil
}
338671
func (b *Buffer) Write(p []byte) (n int, err error) {
	m := b.grow(len(p))
	return copy(b.buf[m:], p), nil
}
48626
func (f *FileWriter) Write(p []byte) (int, error) {
	f.mu.Lock()
	n, err := f.f.Write(p)
	f.mu.Unlock()
	return n, err
}
315148
func (w *Writer) Write(buf []byte) (n int, err error) {
	w.mtx.Lock()
	defer w.mtx.Unlock()
	return w.buf.Write(buf)
}
286203
func (b *ByteBuffer) WriteByte(c byte) error {
	b.Lock()
	defer b.Unlock()
	return b.b.WriteByte(c)
}