ch1 := make(chan string)
fmt.Println("1@", time.Now())
for {
select {
case <-ch1:
fmt.Println("2@", time.Now())
case <-time.After(time.Second * 3):
fmt.Println("3@", time.Now())
return
}
}
1@ 2015-03-19 15:21:45.0547549 +0800 CST
2@ 2015-03-19 15:21:46.0548121 +0800 CST
3@ 2015-03-19 15:21:49.0569838 +0800 CST
ch := make(chan string)
select {
case ch <- "hello":
fmt.Println("send")
default:
fmt.Println("nothing")
}
nothing
https://github.com/golang
http://devs.cloudimmunity.com/gotchas-and-common-mistakes-in-go-golang/
823

被折叠的 条评论
为什么被折叠?



