You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: waitgroup.go
    path of file: ./repos/watermill/pubsub/sync
    
    the code of the file until where you have to start completion: package sync

import (
	"sync"
	"time"
)

// WaitGroupTimeout adds timeout feature for sync.WaitGroup.Wait().
// It retur
    
func WaitGroupTimeout(wg *sync.WaitGroup, timeout time.Duration) bool {
	wgClosed := make(chan struct{}, 1)
	go func() {
		wg.Wait()
		wgClosed <- struct{}{}
	}()

	select {
	case <-wgClosed:
		return false
	case <-time.After(timeout):
		return true
	}
}