Go by Example - Non-Blocking Channel Operations
Go by Example
Go is an open source programming language designed for building simple, fast, and reliable software.
Go by Example is a hands-on introduction to Go using annotated example programs. Check out the first example or browse the full list below.
Go by Example: Non-Blocking Channel Operations
普通管道的发送与接收都是阻塞的,然而我们可以使用select的default条件来实现非阻塞的发送,接收和甚至是非阻塞的多路复用的selects
。
1 | package main |
1 | tashuo:golang ta_shuo$ go run non-blocking-channel.go |