Hi, groups I have a question here: package main import "fmt" func main() { ch := make(chan int, 1) if (1 < 2) { fmt.Println("--------"); } for j := 0; j < 100; j += 1 { select { case ch <- 0: fmt.Println("write 0"); case ch <- 1: fmt.Println("write 1"); default: fmt.Println("fuck0000000000000000000000000000"); } i := <- ch fmt.Println("i = ", i); } } I can get write 0, write 1, while never fuck0000000000000000000000000000 why? then I add another line: case ch <- 2: fmt.Println("write 2"); this time I got all write 0, write 1, write 2; so it is not a timing problem. |
--You received this message because you are subscribed to the Google Groups "golang-nuts" group.To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.For more options, visit https://groups.google.com/d/optout.
Hi, groups
I have a question here:
package main
import "fmt"
func main() {
ch := make(chan int, 1)
if (1 < 2) {
fmt.Println("--------");
}
for j := 0; j < 100; j += 1 {
select {
case ch <- 0:
fmt.Println("write 0");
case ch <- 1:
fmt.Println("write 1");
default:
fmt.Println("fuck0000000000000000000000000000");
}
i := <- ch
fmt.Println("i = ", i);
}
}
I can get write 0, write 1, while never fuck0000000000000000000000000000
why?