You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
562 B
Go
52 lines
562 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"sync"
|
|
)
|
|
|
|
func One() {
|
|
Two()
|
|
fmt.Println("One!")
|
|
}
|
|
|
|
func Two() {
|
|
Three()
|
|
fmt.Println("Two!")
|
|
}
|
|
|
|
func Three() {
|
|
fmt.Println("Three!")
|
|
}
|
|
|
|
// Used in the simple example
|
|
// func main() {
|
|
// msg := "Hello debugger"
|
|
// One()
|
|
// fmt.Println(msg)
|
|
|
|
// }
|
|
|
|
// Used for Goroutine debugging
|
|
|
|
func printMe(i int, wg *sync.WaitGroup) {
|
|
defer wg.Done()
|
|
fmt.Printf("I'm a go routine %d\n", i)
|
|
}
|
|
|
|
func main() {
|
|
i := 0
|
|
|
|
var wg sync.WaitGroup
|
|
wg.Add(9)
|
|
|
|
for i < 10 {
|
|
go func(rI int) {
|
|
printMe(rI, &wg)
|
|
}(i)
|
|
i++
|
|
}
|
|
|
|
wg.Wait()
|
|
}
|