I have some code which looks like this:
package main
import (
"fmt"
)
func main() {
a, b := make(chan string), make(chan string)
go func() { a <- "a" }()
go func() { b <- "b" }()
for {
select {
case s := <-a:
fmt.Println("got", s)
case s := <-b:
fmt.Println("got", s)
}
}
}
<http://talks.golang.org/2013/advconc.slide#29> presenation. When I compile
the code above and run the program I get this error message:
got a
got b
fatal error: all goroutines are asleep - deadlock!
goroutine 1 [select]:
main.main()
C:/Dev/Misc/Go/goprojects/src/Scratch/main.go:13 +0x564
The reason for creating this thread is now not to lament about the fatalfatal error: all goroutines are asleep - deadlock!
goroutine 1 [select]:
main.main()
C:/Dev/Misc/Go/goprojects/src/Scratch/main.go:13 +0x564
error. What I'm interested in is to understand how Go detects that all
goroutines are asleep. Is this simply a timeout that goes off?
Thanks, Haddock
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.