#147·conc

Possible modification to Goal #1 Example

Author: juroberttybCreated Dec 19, 2024Updated Dec 19, 2024

Just wondering, for Goal #1 in Readme, the 2nd approach seems to remove the required modification in startTheThing which receives conc.WaitGroup as function parameter, would that make it look simpler for adopting conc lib?

I misunderstood it on the first glance.

  • 1st (original one)
func main() {
    var wg conc.WaitGroup
    defer wg.Wait()

    startTheThing(&wg)
}

func startTheThing(wg *conc.WaitGroup) {
    wg.Go(func() { ... })
}
  • 2nd
func main() {
    var wg conc.WaitGroup
    defer wg.Wait()

    func(wg *conc.WaitGroup) {
        wg.Go(startTheThing(...))
    }(&wg)
}

func startTheThing() {
    ...
}