Files
isp-admin-service/vendor/github.com/txix-open/isp-kit/http/httpcli/b_pool.go
T

24 lines
357 B
Go

package httpcli
import (
"bytes"
"sync"
)
// nolint:gochecknoglobals,mnd
var (
bpool = sync.Pool{New: func() any {
return bytes.NewBuffer(make([]byte, 1024))
}}
)
func acquireBuffer() *bytes.Buffer {
buf := bpool.Get().(*bytes.Buffer) // nolint:forcetypeassert
buf.Reset()
return buf
}
func releaseBuffer(buf *bytes.Buffer) {
bpool.Put(buf)
}