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