Write appends the contents of p to the buffer, growing the buffer as needed. The return value n is the length of p; err is always nil. If the buffer becomes too large, Write will panic with ErrTooLarge.
(p []byte)
| 129 | // needed. The return value n is the length of p; err is always nil. If the |
| 130 | // buffer becomes too large, Write will panic with ErrTooLarge. |
| 131 | func (b *Buffer) Write(p []byte) (n int, err error) { |
| 132 | b.startWrite() |
| 133 | m, ok := b.tryGrowByReslice(len(p)) |
| 134 | if !ok { |
| 135 | m = b.grow(len(p)) |
| 136 | } |
| 137 | return copy(b.buf[m:], p), nil |
| 138 | } |
| 139 | |
| 140 | // WriteString appends the contents of s to the buffer, growing the buffer as |
| 141 | // needed. The return value n is the length of s; err is always nil. If the |