关于线程池错误pannic的问题(语言-golang)

请帮我看看我的golang线程池的问题 一直报pannic

package amazonsChess

import (
"errors"
"log"
"sync"
)

type task struct {
rollout func(s *State, n *Node) float64
backupdate func(Wins float64, n *Node) *Node
n *Node
}

type goPool struct {
taskChannel chan *task
maxWaitingNum int
blockThreshold int
passThreshold int
blockState bool
openState bool
waitingTask int
wg sync.WaitGroup

waitingtaskLock sync.Mutex

}

func NewPool(maxWaitingNum, blockThreshold, passThreshold int, s *State, n *Node) *goPool {
pool := &goPool{
taskChannel: make(chan *task, maxWaitingNum),
maxWaitingNum: maxWaitingNum,
blockThreshold: blockThreshold, //最大线程数
passThreshold: passThreshold, //最小线程数
blockState: false, //线程池阻塞
openState: true, //线程池打开
waitingTask: 0, //任务队列任务数
}

go pool.scheduler(s, n)
return pool

}

func (p *goPool) add(rollout func(s *State, n *Node) float64, backupdate func(Wins float64, n *Node) *Node, n *Node) error {
if !p.openState {
return errors.New("pool closed")
}
for p.blockState { //任务队列阻塞就不添加
}

p.taskChannel <- &task{
    rollout:    rollout,
    backupdate: backupdate,
    n:          n,
}

p.waitingtaskLock.Lock()
p.waitingTask++
if p.waitingTask >= p.blockThreshold {
    p.blockState = true
}
p.waitingtaskLock.Unlock()

return nil

}

func (p *goPool) Close() {
p.openState = false
p.wg.Wait()
}

func (p *goPool) scheduler(s *State, n *Node) {
for {
if !p.openState {
return
}

    select {
    case task := <-p.taskChannel:
        go func() {
            //wins := task.rollout(s, n)
            //task.backupdate(wins, n)
            task.backupdate(task.rollout(s, n), n)
            p.wg.Done()
        }() //go worker
        p.waitingtaskLock.Lock()
        p.waitingTask--
        if p.passThreshold >= p.waitingTask {
            p.blockState = false
        }
        p.waitingtaskLock.Unlock()

        p.wg.Add(1)
    }
}

}
func (m *Mcts) threadpool(s *State, n *Node, num int, loop int) {
var p *goPool
p = new(goPool)
err := p.add(m.Rollout, m.Backupdate, n)
if err != nil {
log.Fatal(err)
}
p = NewPool(1000, 500, 100, s, n)
if num == loop {
p.Close()
}
}

panic堆栈信息呢?