type SafeWaitGroup … // Add adds delta, which may be negative, similar to sync.WaitGroup. // If Add with a positive delta happens after Wait, it will return error, // which prevent unsafe Add. func (wg *SafeWaitGroup) Add(delta int) error { … } // Done decrements the WaitGroup counter. func (wg *SafeWaitGroup) Done() { … } // Wait blocks until the WaitGroup counter is zero. func (wg *SafeWaitGroup) Wait() { … }