package main import ( "fmt" "sync" "time" ) func main(){ var wg sync.WaitGroup wg.Add(1) go func(){ defer wg.Done() fmt.Println("1 gorountinue is sleeping") time.Sleep(2) fmt.Println("1 gorountinue exiting") }() wg.Add(1) go func(){ defer wg.Done() fmt.Println("2 gorountinue is sleeping") time.Sleep(2) fmt.Println("2 gorountinue exiting") }() wg.Wait() }