Two issues:
-
don’t copy
sync.WaitGroup
: from the docs:A WaitGroup must not be copied after first use.
-
you need a
wg.Add(1)
before launching your work – to pair with thewg.Done()
wg.Add(1) // <- add this
go func (wg *sync.WaitGroup ...) { // <- pointer
}(&wg, quitSig) // <- pointer to avoid WaitGroup copy
solved Why is WaitGroup.Wait() hanging when using it with go test? [duplicate]