1
2
3
4
5
6
7
8
9
10 package p
11
12 type I1 interface {
13 String()
14 }
15 type I2 interface {
16 String()
17 }
18
19 func F() {
20 var (
21 cr <-chan int
22 cs chan<- int
23 c chan int
24
25 ccr chan (<-chan int)
26 ccs chan chan<- int
27 cc chan chan int
28
29 ok bool
30 )
31
32 select {
33 case ccr <- cr:
34 case ccr <- c:
35 }
36 select {
37 case ccs <- cs:
38 case ccs <- c:
39 }
40 select {
41 case ccr <- c:
42 default:
43 }
44
45 select {
46 case cr = <-cc:
47 case cs = <-cc:
48 case c = <-cc:
49 }
50 select {
51 case cr = <-cc:
52 default:
53 }
54 select {
55 case cr, ok = <-cc:
56 case cs, ok = <-cc:
57 case c = <-cc:
58 }
59
60 var (
61 c1 chan I1
62 c2 chan I2
63 x1 I1
64 x2 I2
65 )
66 select {
67 case c1 <- x1:
68 case c1 <- x2:
69 case c2 <- x1:
70 case c2 <- x2:
71 }
72 select {
73 case x1 = <-c1:
74 case x1 = <-c2:
75 case x2 = <-c1:
76 case x2 = <-c2:
77 }
78 select {
79 case x1, ok = <-c1:
80 case x1, ok = <-c2:
81 case x2, ok = <-c1:
82 case x2, ok = <-c2:
83 }
84 _ = ok
85 }
86
View as plain text