properly handle nil New func in sync.Pool

Этот коммит содержится в:
Jaden Weiss 2019-10-15 21:34:51 -04:00 коммит произвёл Ron Evans
родитель 3eec878a11
коммит a2c7112b1f

Просмотреть файл

@ -8,6 +8,9 @@ type Pool struct {
// Get returns the value of calling Pool.New(). // Get returns the value of calling Pool.New().
func (p *Pool) Get() interface{} { func (p *Pool) Get() interface{} {
if p.New == nil {
return nil
}
return p.New() return p.New()
} }