i think the compiler has identified both problems correctly; c is nil (no
cases) and nothing is receiving from c (deadlock).
package main
func main() {
// var c chan struct{}
c := make(chan struct{})
go func(x chan struct{}) { <-x }(c)
select {
case c <- f():
}
}
func f() struct{} {
println("f called")
return struct{}{}
}
On Wed, Aug 8, 2018 at 12:40 AM Kaveh Shahbazian <[email protected]>
wrote:
> According to this thread, for this program:
>
> package main
>
> func main() {
> var c chan struct{}
>
> select {
> case c <- f():
> }
> }
>
>
> func f() struct{} {
> println("f called")
> return struct{}{}
> }
>
> The error message in the output:
>
> f called
> fatal error: all goroutines are asleep - deadlock!
>
> goroutine 1 [select (no cases)]:
> main.main()
> /path/to/main.go:6 +0x45
>
> Is a bit unclear since it says *select (no cases)* but the function *f*
> is still being called - Go 1.10.3.
>
> --
> 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 [email protected].
> For more options, visit https://groups.google.com/d/optout.
>
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.