Go
文章平均质量分 56
resouer
Baidu, now Netease.
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Go闭包
通过访问外部变量,一个闭包可以维持(keep alive)这些变量。在内部函数和外部函数的例子中,外部函数可以创建局部变量,并且最终退出;但是,如果任何一个或多个内部函数在它退出后却没有退出,那么内部函数就维持了外部函数的局部数据。关键词:weichi原创 2014-04-15 23:03:00 · 3044 阅读 · 0 评论 -
Go methods for types
you can define methods on struct types.The method receiver appears in its own argument list between the funckeyword and the method name.原创 2014-04-16 16:24:34 · 2066 阅读 · 0 评论 -
Go Exercise: Equivalent Binary Trees
packagemainimport("fmt""tour/tree")//Walk walks the tree t sending all values//from the tree to the channel ch.funcWalk(t *tree.Tree, ch chan int) {ift.原创 2014-04-22 10:09:46 · 3425 阅读 · 0 评论 -
Go lang concurrency: select with channels
package mainimport "fmt"func fibonacci(c, quit chan int) { x, y := 0, 1 for { select { case c <- x: x, y = y, x+y case <-quit: fmt.Println("原创 2014-04-21 16:31:05 · 2175 阅读 · 0 评论 -
Go中的make和new
转载自:http://www.cnblogs.com/ghj1976/archive/2013/02/12/2910384.htmlmake用于内建类型(map、slice 和channel)的内存分配。new用于各种类型的内存分配。内建函数new本质上说跟其它语言中的同名函数功能一样:new(T)分配了零值填充的T类型的内存空间,并且返回其地址,即一个*T类型的值。用Go的术转载 2014-04-11 16:56:42 · 17264 阅读 · 1 评论
分享