Simple blogging system written in Go https://goblog.app
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
GoBlog/pkgs/bufferpool/bufferPool.go

23 lines
304 B

package bufferpool
import (
"bytes"
"sync"
)
var bufferPool = sync.Pool{
New: func() any {
return new(bytes.Buffer)
},
}
func Get() *bytes.Buffer {
return bufferPool.Get().(*bytes.Buffer)
}
func Put(bufs ...*bytes.Buffer) {
for _, buf := range bufs {
buf.Reset()
bufferPool.Put(buf)
}
}