Friday, January 2, 2015

Go Channels Tips

- Read from an unbuffered channel:
  blocks (use select).

 - Write to an unbuffered channel:
   blocks.

 - Read from a buffered channel:
   blocks (use select).

 - Write to an buffered channel:
   non blocking as long as there is space left in the buffer.

 - Read from a closed channel:
   non blocking, always return the zero value of the channel type.
  
 - Write to a closed channel:
   panic: runtime error: send on closed channel

 - Read from a nil channel:
   blocks forever.

 - Write to a nil channel:
   blocks forever.

No comments:

Post a Comment