github.com/james-maloney/bufpool

A pool for bytes.Buffer


License
MIT
Install
go get github.com/james-maloney/bufpool

Documentation

Package bufpool

bufpool provides a thin wrapper around sync.Pool that is used to store *bytes.Buffer.

Usage

// Create a new pool
p := bufpool.New()

// Get bytes.Buffer from pool
buf := p.Get()

buf.WriteString("Hello, World!")
fmt.Println(buf.String())

// Put the buffer back into the pool
p.Put(buf)

I've implemented this enough times that this small dependency comes in handy in reducing boilerplate code.