Comment by cedws
You can wrap WaitGroup if you really want to.
You can wrap WaitGroup if you really want to.
something like this would do it:
package main
import (
"sync"
"time"
)
type WaitGroup struct {
sync.WaitGroup
}
func (wg *WaitGroup) Go(fn func()) {
wg.Add(1)
go func() {
defer wg.Done()
fn()
}()
}
func main() {
var wg WaitGroup
wg.Go(func() { time.Sleep(1 * time.Second) })
wg.Wait()
}
It's called struct embedding, there an article about it in Go by Example if you're interested: https://gobyexample.com/struct-embedding
Can you provide an example please?