Debian Codegraph @

_test/select.go

raw symbols SCIP
1 package main
2
3 import "time"
4 import "fmt"
5
6 func main() {
7 c1 := make(chan string)
8 c2 := make(chan string)
9
10 go func() {
11 time.Sleep(1e9)
12 c1 <- "one"
13 }()
14 go func() {
15 time.Sleep(2e9)
16 c2 <- "two"
17 }()
18
19 for i := 0; i < 2; i++ {
20 fmt.Println("start for")
21 select {
22 case msg1 := <-c1:
23 fmt.Println("received", msg1)
24 fmt.Println("finish 1")
25 case msg2 := <-c2:
26 fmt.Println("received #2", msg2)
27 }
28 fmt.Println("end for")
29 }
30 fmt.Println("Bye")
31 }