Skip to content

Instantly share code, notes, and snippets.

@countingtoten
Created August 18, 2017 17:22
Show Gist options
  • Save countingtoten/3eb9e85e5f00590bb4aa02f2a1e965d0 to your computer and use it in GitHub Desktop.
Save countingtoten/3eb9e85e5f00590bb4aa02f2a1e965d0 to your computer and use it in GitHub Desktop.
&sync.Pool{
New: func() interface{} {
buf := bytes.NewBuffer(nil)
buf.Grow(2048)
return buf
},
}
}
buf := BufferPool.Get().(*bytes.Buffer)
defer BufferPool.Put(buf)
buf.Reset()
io.CopyN(buf, r.Body, r.ContentLength)
buf.Bytes()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment