A Tour of Go: Basics 3
Struct 用指针和用变量名引用struct里的值,用法是一样的。Struct初始化语法: type Vertex struct { X, Y int } var ( v1 = Vertex{1, 2} // has type Vertex v2 = Vertex{X: 1} // Y:0 is implicit v3 = Vertex{} // X:0 and Y:0 p = &Vertex{1, 2} // has type *Vertex ) Array 数据长度是固定的,在定义时指定。 Slices Slices的概念与Python中的概念类似,是Array的子集。slice只是数组的引用,因此修改slice值就是修改数组里的值。[]int{1,2,3}语法含义是先定义一个数组,再...阅读全文