On Fri, Sep 23, 2016 at 10:00 AM,  <ishantagarwal1...@gmail.com> wrote:
> Considering what is mentioned in the video, it looks like whenever a second
> has gone by and a message is not returned only then the exit from loop  will
> happen.
> Which means the loop may run indefinitely as well if boring function keeps
> on returning something or the other within a second on the channel returned
> by it..

Yes, you're correct, if that's not the desired behavior this should be written:

>     t := time.After(1 * time.Second)
>     for {
>         select {
>         case s := <-c:
>             fmt.Println(s)
>         case <-t:
>             fmt.Println("You're too slow.")
>             return
>         }
>     }



—Sam


-- 
Sam Whited
pub 4096R/54083AE104EA7AD3

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to