This is a created article in which the information may have evolved or changed.
Chan is a very important concept for Golang to communicate or share data between different goroutine, which is the way go recommends sharing data.
Chan has a default deadlock detection mechanism, such as this code
Http://play.golang.org/p/_0UWFWiGOr
Run the time will prompt: Fatal Error:all goroutines is asleep–deadlock!
Chan can be combined with SELECT, and when Chan is combined with SELECT, there is an interesting phenomenon that Chan becomes non-blocking
What's more interesting is time. Timer,chan with SELECT, each time a Select Chan case occurs, the timer is reset. An extreme example, in Select, only the timer and default, the program will be a few seconds to drain the system resources, do not know the calculation is not a bug, the code here:
Http://play.golang.org/p/WYA-0HmUEH
Also, if there is a timer and default in a select, then the timer will never return.
The reason seems to be that every time the select is over, it resets the timer and does not know if my understanding is biased.