23 September 2017
type Vertex struct {
        X int
        Y int
}

func main() {
        fmt.Println(Vertex{1, 2})  // {1 2}
}



type Vertex struct {
        X int
        Y int
}

func main() {
        v := Vertex{1, 2}
        v.X = 4
        fmt.Println(v.X)  // 4


type Vertex struct {
        X int
        Y int
}

func main() {
        v := Vertex{1, 2}
        p := &v
        p.X = 1e9
        fmt.Println(v)
}
type Human struct {
        name   string
        age    int
        weight int
}

type Student struct {
        Human // 匿名字段,那么默认 Student 就包含了 Human 的所有字段
        name  string
}

func main() {
        mark := Student{Human{"Mark", 25, 120}, "Computer Science"}

        pp.Println(mark)
        pp.Println(mark.age)   // 25
        pp.Println(mark.name)  // Computer Science
}