Skip to content

Commit 8daf04f

Browse files
committed
Fixed pools golint warnings for go1.7
Signed-off-by: Lei Jitang <[email protected]>
1 parent 953699f commit 8daf04f

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

utils/pools.go

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ func init() {
4646
// newBufioReaderPoolWithSize is unexported because new pools should be
4747
// added here to be shared where required.
4848
func newBufioReaderPoolWithSize(size int) *BufioReaderPool {
49-
pool := sync.Pool{
49+
pool := &sync.Pool{
5050
New: func() interface{} { return bufio.NewReaderSize(nil, size) },
5151
}
52-
return &BufioReaderPool{pool: pool}
52+
return &BufioReaderPool{pool: *pool}
5353
}
5454

5555
// Get returns a bufio.Reader which reads from r. The buffer size is that of the pool.
@@ -65,14 +65,6 @@ func (bufPool *BufioReaderPool) Put(b *bufio.Reader) {
6565
bufPool.pool.Put(b)
6666
}
6767

68-
// Copy is a convenience wrapper which uses a buffer to avoid allocation in io.Copy.
69-
func Copy(dst io.Writer, src io.Reader) (written int64, err error) {
70-
buf := BufioReader32KPool.Get(src)
71-
written, err = io.Copy(dst, buf)
72-
BufioReader32KPool.Put(buf)
73-
return
74-
}
75-
7668
// BufioWriterPool is a bufio writer that uses sync.Pool.
7769
type BufioWriterPool struct {
7870
pool sync.Pool
@@ -81,10 +73,10 @@ type BufioWriterPool struct {
8173
// newBufioWriterPoolWithSize is unexported because new pools should be
8274
// added here to be shared where required.
8375
func newBufioWriterPoolWithSize(size int) *BufioWriterPool {
84-
pool := sync.Pool{
76+
pool := &sync.Pool{
8577
New: func() interface{} { return bufio.NewWriterSize(nil, size) },
8678
}
87-
return &BufioWriterPool{pool: pool}
79+
return &BufioWriterPool{pool: *pool}
8880
}
8981

9082
// Get returns a bufio.Writer which writes to w. The buffer size is that of the pool.

0 commit comments

Comments
 (0)