Tickers _ golang

摘要: Timers are for when you want to do something once in the future - tickers are for when you want to do something repeatedly at regular intervals. Here'... 阅读全文
posted @ 2015-03-18 13:22 xjk112 阅读(263) 评论(0) 推荐(0) 编辑

Timers _ golang

摘要: We often want to execute Go code at some point in the future, or repeatedly at some interval. Go's built-in timer and ticker features make both od the... 阅读全文
posted @ 2015-03-18 13:16 xjk112 阅读(190) 评论(0) 推荐(0) 编辑

range over channel _ golang

摘要: In a previous example we saw how for and range provide iteration over basic data structures. We can alse use this syntax to iterate over values receiv... 阅读全文
posted @ 2015-03-17 13:50 xjk112 阅读(211) 评论(0) 推荐(0) 编辑

closing channel _ golang

摘要: Closing a channel indicates that no more values will be sent on it. This can be useful to communicate completion to the channel's receivers.package ma... 阅读全文
posted @ 2015-03-17 13:44 xjk112 阅读(145) 评论(0) 推荐(0) 编辑

non-blocking channel options _ golang

摘要: Basic sends and receives on channels are blocking. However, we can use select with a default clause to implement non-blocking sends, receives, and eve... 阅读全文
posted @ 2015-03-17 13:30 xjk112 阅读(233) 评论(0) 推荐(0) 编辑

timeouts _ golang

摘要: Timeouts are import for programs that connect to external resources or that otherwise need to bound execution time. Implementing timeouts in Go is eas... 阅读全文
posted @ 2015-03-16 13:59 xjk112 阅读(252) 评论(0) 推荐(0) 编辑

select.go

摘要: Go's select lets you wait on multiple channel operations. Combing goroutines and channels with select is a poweful feature of Gopackage mainimport ( ... 阅读全文
posted @ 2015-03-16 13:46 xjk112 阅读(140) 评论(0) 推荐(0) 编辑

channel directions _ golang

摘要: When using channels as function parameters, you can specify if a channel is meant to only send or receive values. This specificity increases the type-... 阅读全文
posted @ 2015-03-16 13:39 xjk112 阅读(215) 评论(0) 推荐(0) 编辑

channel synchronization _ golang

摘要: we can use channels to sychronize execution across goroutines. Here's an example of using a blocking receive to to wait for a goroutine to finshpackag... 阅读全文
posted @ 2015-03-16 13:29 xjk112 阅读(197) 评论(0) 推荐(0) 编辑

channel _ buffering

摘要: By default channels are unbuffered, meaning that they will only accept sends(chan <-) if there is a corresponding receive (<- chan) ready to receive t... 阅读全文
posted @ 2015-03-15 15:05 xjk112 阅读(101) 评论(0) 推荐(0) 编辑