go 标签

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
func mian() {
c := make(chan string,1)
defer close(c)
go func() {
for i := 0; i < 10; i++ {
c <- fmt.Sprint("baipeng", i)
}
}()

hello:
for {
select {
case s := <-c:
fmt.Println(s)
default:
break hello
}
}
}