On Sun, May 5, 2019 at 12:06 PM Louki Sumirniy
<louki.sumirniy.stal...@gmail.com> wrote:

> Is there ANY other use case for waitgroup other than preventing a goroutine 
> leak or ensuring that it empties the channels at the end of execution?

I don't think this question is related to the correctness of your
shorter implementation of WaitGroup. Anyway, what about such code?

        var wg sync.WaitGroup

        func main() {
                defer wg.Wait()

                if someCondition {
                        for i := 0; i < 4; i++ {
                                wg.Add(1)
                                go worker(i)
                        }
                }
                ...
        }

        func worker(i int) {
                defer wg.Done()

                ...
        }

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to