package main import "fmt" import "sync" var wg sync.WaitGroup func main() { for i := 0; i < 5; i++ { go func() { defer wg.Done() wg.Add(1) fmt.Println("Hello World") }() } wg.Wait() }