Skip to content

Commit b73f3ab

Browse files
committed
boring
1 parent 88f95ed commit b73f3ab

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

boring.go

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"time"
6+
)
7+
8+
func boring(msg string, c chan string) {
9+
for i := 0; ; i++ {
10+
c <- fmt.Sprintf("%s %d", msg, i)
11+
time.Sleep(time.Duration(1000) * time.Millisecond)
12+
}
13+
}
14+
15+
func main() {
16+
c := make(chan string)
17+
go boring("boring", c)
18+
for i := 0; i < 5; i++ {
19+
fmt.Printf("You say: %q\n", <-c)
20+
}
21+
fmt.Println("You're boring; I'm leaving.")
22+
23+
}

0 commit comments

Comments
 (0)