OLD | NEW |
| 1 // +build OMIT |
| 2 |
1 package main | 3 package main |
2 | 4 |
3 import ( | 5 import ( |
4 "fmt" | 6 "fmt" |
5 "time" | 7 "time" |
6 ) | 8 ) |
7 | 9 |
8 func main() { | 10 func main() { |
9 go say("ho!", 2*time.Second) // & | 11 go say("ho!", 2*time.Second) // & |
10 go say("hey!", 1*time.Second) // & | 12 go say("hey!", 1*time.Second) // & |
11 | 13 |
12 // Make main sleep for 4 seconds so goroutines can finish | 14 // Make main sleep for 4 seconds so goroutines can finish |
13 time.Sleep(4 * time.Second) | 15 time.Sleep(4 * time.Second) |
14 } | 16 } |
15 | 17 |
16 // say prints text after sleeping for X secs | 18 // say prints text after sleeping for X secs |
17 func say(text string, secs time.Duration) { | 19 func say(text string, secs time.Duration) { |
18 time.Sleep(secs) | 20 time.Sleep(secs) |
19 fmt.Println(text) | 21 fmt.Println(text) |
20 } | 22 } |
OLD | NEW |