github.com/unigraph-dev/dgraph@v1.1.1-0.20200923154953-8b52b426f765/dgraph/cmd/alpha/thoughts.md (about) 1 1. Select v/s Range 2 3 2. sync.WaitGroup. 4 5 func handle(..) { 6 wg.Add(1) 7 ... 8 wg.Done() 9 } 10 11 func main() { 12 wg := new(sync.WaitGroup) 13 for i := 0; i < N; i++ { 14 go handle(..) 15 } 16 wg.Wait() 17 } 18 19 The above wouldn't work, because goroutines don't necessarily get scheduled immediately. 20 So, wg.Add(1) wouldn't get called, which means wg.Wait() wouldn't block, and the program 21 would finish execution before goroutines had a chance to be run.