Grow grows the buffer's capacity, if necessary, to guarantee space for another n bytes. After Grow(n), at least n bytes can be written to the buffer without another allocation. If n is negative, Grow will panic. If the buffer can't grow it will panic with ErrTooLarge.
(n int)
| 163 | // If n is negative, Grow will panic. |
| 164 | // If the buffer can't grow it will panic with ErrTooLarge. |
| 165 | func (b *Buffer) Grow(n int) { |
| 166 | if n < 0 { |
| 167 | panic("bytes.Buffer.Grow: negative count") |
| 168 | } |
| 169 | m := b.grow(n) |
| 170 | b.buf = b.buf[0:m] |
| 171 | } |
| 172 | |
| 173 | // Write appends the contents of p to the buffer, growing the buffer as |
| 174 | // needed. The return value n is the length of p; err is always nil. If the |