stefanos82 13 hours ago

Can you provide an example please?

  • listeria 13 hours ago

    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()
      }