In the first example of the theory, you used a single channel to wait for the result:
package main
import (
"time"
)
func main() {
sync := make(chan bool, 1)
go func() {
time.Sleep(time.Second)
sync <- true
}()
<-sync
}
Using a similar principle, make the parent goroutine wait for the completion of processing of multiple child goroutines. The number of launched goroutines is read from the input.