目录
定义结构体
type node struct {
val int
}
定义类型
type num int // num类型与int类型等价
定义interface
type sort interface {
}
定义函数类型
type handler func(msg string) int
类型别名
type I int
type D = int
类型定义与类型别名的区别:
类型定义是完全定义了一种全新的类型,而类型别名只是给现有的类型取了一个别名。
可以给某些类型取别名,使用方便
type strMap2Any = map[string]interface {}