channel _ golang

摘要: Channels are the pipes that connect concurrent goroutines. You can send values into channels from one goroutine andreceive those values into another g... 阅读全文
posted @ 2015-03-15 14:54 xjk112 阅读(170) 评论(0) 推荐(0) 编辑

goroutines _ golang

摘要: A goroutine is a loghtweight thread of executionpackage mainimport ( "fmt")func f(form string) { for i := 0; i < 3; i++ { fmt.Println(for... 阅读全文
posted @ 2015-03-15 14:43 xjk112 阅读(202) 评论(0) 推荐(0) 编辑

errors _ golang

摘要: In Go it's idiomatic to communicate errors via an explicit, separate return value. this constrasts errors via an explicit, separate return value. This... 阅读全文
posted @ 2015-03-14 18:44 xjk112 阅读(236) 评论(0) 推荐(0) 编辑

interface _ golang

摘要: Interfaces are named collections of methods signaturespackage mainimport ( "fmt" "math")type geometry interface { area() float64 perim() f... 阅读全文
posted @ 2015-03-14 18:08 xjk112 阅读(240) 评论(0) 推荐(0) 编辑

methods for struct _ golang

摘要: Go supports methods defined on struct typespackage mainimport ( "fmt")type rect struct { width, height int}func (r *rect) area() int { return... 阅读全文
posted @ 2015-03-14 17:55 xjk112 阅读(211) 评论(0) 推荐(0) 编辑

structs _ golang

摘要: Go's structs are typed collections of fields. They're useful for grouping data together to form recordspackage mainimport ( "fmt")type person struc... 阅读全文
posted @ 2015-03-14 17:47 xjk112 阅读(110) 评论(0) 推荐(0) 编辑

Pointers _ golang

摘要: Go support pointers, allowing you to pass references to values and records within your programpackage mainimport ( "fmt")func zeroval(ival int) { ... 阅读全文
posted @ 2015-03-14 17:39 xjk112 阅读(147) 评论(0) 推荐(0) 编辑

resursion _ golang

摘要: Go support recursive functions. Here's a classic factorial examplepackage mainimport ( "fmt")func fact(n int) int { if n == 0 { return 1 ... 阅读全文
posted @ 2015-03-14 17:32 xjk112 阅读(179) 评论(0) 推荐(0) 编辑

closures _ golang

摘要: Go supports anonymous functions, which can form closures. Anonymous functions are useful when you want to define a function inline without having to n... 阅读全文
posted @ 2015-03-14 17:28 xjk112 阅读(171) 评论(0) 推荐(0) 编辑

variadic function _ golang

摘要: Variadic functions can be called with any number of trailing arguments. For example, fmt.Println is a common variadic functionpackage mainimport ( ... 阅读全文
posted @ 2015-03-14 17:20 xjk112 阅读(140) 评论(0) 推荐(0) 编辑