WriteString appends the contents of s to the buffer, growing the buffer as needed. The return value n is the length of s; err is always nil. If the buffer becomes too large, WriteString will panic with ErrTooLarge.
(s string)
| 141 | // needed. The return value n is the length of s; err is always nil. If the |
| 142 | // buffer becomes too large, WriteString will panic with ErrTooLarge. |
| 143 | func (b *Buffer) WriteString(s string) (n int, err error) { |
| 144 | b.startWrite() |
| 145 | m, ok := b.tryGrowByReslice(len(s)) |
| 146 | if !ok { |
| 147 | m = b.grow(len(s)) |
| 148 | } |
| 149 | return copy(b.buf[m:], s), nil |
| 150 | } |
| 151 | |
| 152 | // WriteByte emits a single byte. |
| 153 | func (b *Buffer) WriteByte(s byte) error { |