buffer:Go #golang的可组合缓冲区
缓冲
用法
以下缓冲区提供了简单的独特行为,这些行为组成时可创建复杂的缓冲策略。 与github.com/djherbis/nio一起用于io.Pipe和io.Copy缓冲实现。
例如:
import (
"github.com/djherbis/buffer"
"github.com/djherbis/nio"
"io/ioutil"
)
// Buffer 32KB to Memory, after that buffer to 100MB chunked files
buf := buffer . NewUnboundedBuffer ( 32 * 1024 , 100 * 1024 * 1024 )
nio . Copy ( w , r , buf ) // Reads from r, writes to buf, reads from buf writes to