I have some code which looks like this:

package main

import (



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)



The code is modified based on the code in this
<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]:


C:/Dev/Misc/Go/goprojects/src/Scratch/main.go:13 +0x564
The reason for creating this thread is now not to lament about the fatal
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.

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 4 | next ›
Discussion Overview
groupgolang-nuts @
postedMay 28, '15 at 10:55a
activeMay 28, '15 at 1:16p

3 users in discussion

Haddock: 2 posts Dave Cheney: 1 post Jan Mercl: 1 post



site design / logo © 2022 Grokbase