Skip to content

Instantly share code, notes, and snippets.

@cloudhead
Created May 8, 2012 15:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cloudhead/2636362 to your computer and use it in GitHub Desktop.
Save cloudhead/2636362 to your computer and use it in GitHub Desktop.
package main
func main() {
println("starting..")
go func() {
println("hello") // This never prints
}()
for {}
}
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
Copy link


starting..
hello
throw: all goroutines are asleep - deadlock!

goroutine 1 [select (no cases)]:
main.main()
        /Users/sean/src/testgo/test.go:12 +0x44

goroutine 2 [syscall]:
created by runtime.main
        /usr/local/go/src/pkg/runtime/proc.c:221

shell returned 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment