getBuffer retrieves a buffer from the pool for internal use. The buffer is pre-allocated and ready for writing operations. Always pair with putBuffer() to return the buffer to the pool.
()
| 35 | // The buffer is pre-allocated and ready for writing operations. |
| 36 | // Always pair with putBuffer() to return the buffer to the pool. |
| 37 | func getBuffer() *bytes.Buffer { |
| 38 | return bufferPool.Get().(*bytes.Buffer) |
| 39 | } |
| 40 | |
| 41 | // putBuffer returns a buffer to the pool after use. |
| 42 | // The buffer is reset (cleared) before being returned to the pool. |