forked from TrueCloudLab/certificates
24 lines
301 B
Go
24 lines
301 B
Go
|
// Package buffer implements a reusable buffer pool.
|
||
|
package buffer
|
||
|
|
||
|
import (
|
||
|
"bytes"
|
||
|
"sync"
|
||
|
)
|
||
|
|
||
|
func Get() *bytes.Buffer {
|
||
|
return pool.Get().(*bytes.Buffer)
|
||
|
}
|
||
|
|
||
|
func Put(b *bytes.Buffer) {
|
||
|
b.Reset()
|
||
|
|
||
|
pool.Put(b)
|
||
|
}
|
||
|
|
||
|
var pool = sync.Pool{
|
||
|
New: func() interface{} {
|
||
|
return new(bytes.Buffer)
|
||
|
},
|
||
|
}
|