我一直在读A Tour of Go来学习Go-Lang,到目前为止进展顺利.
我目前正在上Struct Fields课,下面是右边的示例代码:
package main
import "fmt"
type Vertex struct {
X int
Y int
}
func main() {
v := Vertex{1, 2}
v.X = 4
fmt.Println(v.X)
}
看一下第3行:
type Vertex struct {
我不明白的是,type
这个关键字是做什么用的,为什么会在那里?