multiple return values _ golang

摘要: Go has built-in support for multiple return values. This feature is used often in idiomatic Go, for example to return both result and error values fro... 阅读全文
posted @ 2015-03-14 17:14 xjk112 阅读(135) 评论(0) 推荐(0) 编辑

functions _ golang

摘要: Functions are central in Go. We'll learn about functions with a few different examplespackage mainimport ( "fmt")func plus(a int, b int) int { r... 阅读全文
posted @ 2015-03-14 17:08 xjk112 阅读(150) 评论(0) 推荐(0) 编辑

range _ golang

摘要: range iterates over of elements in variety of data structures. Let's see how use range with some of the data structures we've already leranedpackage m... 阅读全文
posted @ 2015-03-13 15:00 xjk112 阅读(168) 评论(0) 推荐(0) 编辑

map _ golang

摘要: Maps are Go's built-in associative data type(sometimes called hashes or dits in other languages)package mainimport ( "fmt")func main() { m := ma... 阅读全文
posted @ 2015-03-13 14:50 xjk112 阅读(176) 评论(0) 推荐(0) 编辑

slices _ golang

摘要: Slices are a key data type in Go, giving a more powerful interface to sequences than arrayspackage mainimport ( "fmt")func main() { s := make([]... 阅读全文
posted @ 2015-03-13 14:41 xjk112 阅读(271) 评论(0) 推荐(0) 编辑

array _ golang

摘要: in Go, an array is a numbered sequence of elements of a specific lengthpackage mainimport ( "fmt")func main() { var a [5]int fmt.Println("emp... 阅读全文
posted @ 2015-03-12 13:52 xjk112 阅读(182) 评论(0) 推荐(0) 编辑

switch _ golang

摘要: switch 1: 在条件语句中,可以写多条的语句 2: 也可以不添加语句package mainimport ( "fmt" "time")func main() { i := 2 fmt.Println("write ", i, " as ") switch ... 阅读全文
posted @ 2015-03-12 13:45 xjk112 阅读(214) 评论(0) 推荐(0) 编辑

if else _ golang

摘要: if else 在 golangpackage mainimport ( "fmt")func main() { if 7%2 == 0 { fmt.Println("7 is even") } else { fmt.Println("7 is odd"... 阅读全文
posted @ 2015-03-12 13:35 xjk112 阅读(195) 评论(0) 推荐(0) 编辑

for _ golang

摘要: for 是 golang 唯一的 looping 结构,package mainimport ( "fmt")func main() { i := 1 for i <= 3 { fmt.Println(i) i += 1 } for j :=... 阅读全文
posted @ 2015-03-11 15:33 xjk112 阅读(105) 评论(0) 推荐(0) 编辑

constants _ golang

摘要: golang 中支持 长量 const or staticpackage mainimport ( "fmt" "math")const s string = "constant"const a = 3000func main() { const s = 3000 fmt.P... 阅读全文
posted @ 2015-03-11 13:30 xjk112 阅读(181) 评论(0) 推荐(0) 编辑