Tim Vaillancourt 47d49c6b92
Add go mod (#935)
* Add a go.mod file

* run go mod vendor again

* Move to a well-supported ini file reader

* Remove GO111MODULE=off

* Use go 1.16

* Rename github.com/outbrain/golib -> github.com/openark/golib

* Remove *.go-e files

* Fix for `strconv.ParseInt: parsing "": invalid syntax` error

* Add test for '[osc]' section

Co-authored-by: Nate Wernimont <nate.wernimont@workiva.com>
2021-06-24 20:19:37 +02:00

36 lines
498 B
Go

package utils
import (
"bytes"
"sync"
)
var (
bytesBufferPool = sync.Pool{
New: func() interface{} {
return &bytes.Buffer{}
},
}
bytesBufferChan = make(chan *bytes.Buffer, 10)
)
func BytesBufferGet() (data *bytes.Buffer) {
select {
case data = <-bytesBufferChan:
default:
data = bytesBufferPool.Get().(*bytes.Buffer)
}
data.Reset()
return data
}
func BytesBufferPut(data *bytes.Buffer) {
select {
case bytesBufferChan <- data:
default:
bytesBufferPool.Put(data)
}
}