Channels are used to communicate between threads. Channels are first-in, first-out (FIFO) queues. You can push objects on to the queue and pull from the front asynchronously. Each channel can only support one data type. Channels are blocking by default, but can be made nonblocking with a select statement. Like slices and maps, channels must be initialized before use with the make() function.
The saying in Go is Do not communicate by sharing memory; instead, share memory by communicating. Read more about this philosophy at https://blog.golang.org/share-memory-by-communicating.
Here is an example program that demonstrates basic channel usage:
package mainimport ( "log" "time")// Do some processing that takes a long time// in a separate ...