Created
August 18, 2017 17:22
-
-
Save countingtoten/3eb9e85e5f00590bb4aa02f2a1e965d0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
&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