Created
May 8, 2012 15:32
-
-
Save cloudhead/2636362 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
func main() { | |
println("starting..") | |
go func() { | |
println("hello") // This never prints | |
}() | |
for {} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
//import "time" | |
func main() { | |
c1 := make(chan int) | |
c2 := make(chan int) | |
println("starting..") | |
go func() { | |
<-c2 // this doesn't work! | |
}() | |
for { | |
select { | |
case c1 <- 42: | |
println("sent to c1") | |
case c2 <- 42: | |
println("sent to c2") | |
default: | |
// Ignore | |
} | |
} | |
} | |
streadway
commented
May 8, 2012
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment