shapeio:Golang io.Reader和io.Writer的流量整形器
形状
Golang io.Reader和io.Writer的流量整形器
import "github.com/fujiwara/shapeio"
func ExampleReader () {
// example for downloading http body with rate limit.
resp , _ := http . Get ( "http://example.com" )
defer resp . Body . Close ()
reader := shapeio . NewReader ( resp . Body )
reader . SetRateLimit ( 1024 * 10 ) // 10KB/sec
io . Copy ( ioutil . Discard , reader )
}
func ExampleWriter () {
// ex