FAQ
Basically the problem is if I define a function which returns a named value
which is a channel and I don't initialize the channel I end up with a
deadlock. Here's a demo

http://play.golang.org/p/qW2i9Kcnoa

From what I understood Go will initialize all variables, which does make
sense for integers and other primitive types, but what happens in the case
of a channel? Why does it silently swallow things instead of failing at
compile time (or even at runtime)?

--
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/groups/opt_out.

Search Discussions

  • Daniel Morsing at Mar 19, 2013 at 4:38 pm

    On Tue, Mar 19, 2013 at 4:34 PM, Jakub Arnold wrote:
    From what I understood Go will initialize all variables, which does make
    sense for integers and other primitive types, but what happens in the case
    of a channel? Why does it silently swallow things instead of failing at
    compile time (or even at runtime)?
    A channel will get a be default initialized to a nil channel. Any send
    or receive on such a channel will block forever.

    --
    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/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedMar 19, '13 at 4:27p
activeMar 19, '13 at 4:38p
posts2
users2
websitegolang.org

2 users in discussion

Jakub Arnold: 1 post Daniel Morsing: 1 post

People

Translate

site design / logo © 2022 Grokbase