fix #453 (select recv))

This commit is contained in:
xushiwei
2024-07-07 16:03:41 +08:00
parent c0ae681d69
commit 7b41a0ff16
2 changed files with 43 additions and 4 deletions

21
_demo/chandemo/chan.go Normal file
View File

@@ -0,0 +1,21 @@
package main
func main() {
c1 := make(chan string)
c2 := make(chan string, 1)
go func() {
c1 <- "ch1"
}()
go func() {
c2 <- "ch2"
}()
for i := 0; i < 2; i++ {
select {
case msg1 := <-c1:
println(msg1)
case msg2 := <-c2:
println(msg2)
}
}
}