string functions _ golang

摘要: The standard libarary's strings package provides many useful string-related functions. Here are some examples to give you a sense of the packagepackag... 阅读全文
posted @ 2015-03-24 13:30 xjk112 阅读(207) 评论(0) 推荐(0) 编辑

collection function _ golang

摘要: We often need our programs to perform operations on collection of data, like selecting all items that satisfy a given predicate or mapping all items t... 阅读全文
posted @ 2015-03-23 14:04 xjk112 阅读(280) 评论(0) 推荐(0) 编辑

defer _ golang

摘要: Defer is used to ensure that a function call is performed later in a program's execution, usually for purposes of cleanup. defer is often used wheree.... 阅读全文
posted @ 2015-03-23 13:44 xjk112 阅读(151) 评论(0) 推荐(0) 编辑

sorting functions _ golang

摘要: Sometimes we'll want to sort a collection by something other than its natural order. For example, suppose we wanted to sort strings by their length in... 阅读全文
posted @ 2015-03-20 15:37 xjk112 阅读(196) 评论(0) 推荐(0) 编辑

sorting _ golang

摘要: Go's sort package implements sorting for builtins and user-defined types. We'll look at sorting for builtins firstpackage mainimport ( "fmt" "so... 阅读全文
posted @ 2015-03-20 14:54 xjk112 阅读(173) 评论(0) 推荐(0) 编辑

statefule goroutines _ golang

摘要: In the previous example we used explicit locking with mutexes to synchronize access to shared state across multiple goroutines. Another option is to u... 阅读全文
posted @ 2015-03-20 14:43 xjk112 阅读(353) 评论(0) 推荐(0) 编辑

atomic counters _ golang

摘要: The primary mechanism for managing state in Go is communication over channels. We saw this for example with worker pools. There are a few other option... 阅读全文
posted @ 2015-03-19 14:08 xjk112 阅读(227) 评论(0) 推荐(0) 编辑

mutexes _ golang

摘要: In the previous example we saw how to manage simple counter state using atomic operations. For more complex state we can use a mutex to safetly access... 阅读全文
posted @ 2015-03-19 13:54 xjk112 阅读(302) 评论(0) 推荐(0) 编辑

rate limiting _ golang

摘要: Rate limiting is an import mechanism for controlling resource utilzation and maintaining quality of service. Go elegantly supports rate with goroutine... 阅读全文
posted @ 2015-03-19 13:44 xjk112 阅读(243) 评论(0) 推荐(0) 编辑

workerPool _ golang

摘要: In this example we'll look at how to implement a worker pool using goroutines and channelspackage mainimport ( "fmt" "time")func worker(id int, ... 阅读全文
posted @ 2015-03-18 13:30 xjk112 阅读(533) 评论(0) 推荐(0) 编辑