摘要:
在《The Little Go Book》里有关于 channel 的一段话: In other words, a goroutine that has data can pass it to another goroutine via a channel. The result is that, 阅读全文
摘要:
The Little Go Book http://openmymind.net/The-Little-Go-Book/ 里面介绍了 Embedding 的实现方法, 示例程序如下(有修改): 其中,特别需要注意的是,虽然 goku 可以“免费”获得 Person 的全部能力(比如 .Name 和 阅读全文
摘要:
Every package should have a package comment, a block comment preceding the package clause. Every exported (capitalized) name in a program should have 阅读全文
摘要:
Effective Go 里的一个小节 Interfaces and methods (https://golang.org/doc/effective_go.html#interface_methods) 介绍了把 method 附加到 function 上的方法。 1. 首先,创建一种 type 阅读全文
摘要:
A Tour of Go concurrency >> sync.Mutex https://tour.golang.org/concurrency/9 golang 里的 map 并不是 concurrency-safe 的,也就是说,当多个 goroutine 对同一个 map 进行操作时,有可 阅读全文
摘要:
A Tour of Go Exercise: Equivalent Binary Trees https://tour.golang.org/concurrency/7 检查两棵二叉树是否包含相同的数值,这题难度稍大,有几个难点。 答案如下: 其中,函数 walk 用递归方法遍历二叉树 在 walk 阅读全文