一、类型系统概览
Go 是一门强类型静态语言,所有变量在编译时确定类型。Go 的类型系统简洁而强大,不支持隐式类型转换,这使得代码更加安全可靠。
Go 类型体系
├── 基本类型(Basic Types)
│ ├── 布尔型:bool
│ ├── 整数型:int, int8, int16, int32, int64
│ │ uint, uint8, uint16, uint32, uint64, uintptr
│ ├── 浮点型:float32, float64
│ ├── 复数型:complex64, complex128
│ ├── 字符型:byte(uint8), rune(int32)
│ └── 字符串:string
├── 复合类型(Composite Types)
│ ├── 数组:[N]T
│ ├── 切片:[]T
│ ├── 映射:map[K]V
│ └── 结构体:struct
├── 引用类型(Reference Types)
│ ├── 指针:*T
│ ├── 切片:[]T
│ ├── 映射:map[K]V
│ ├── 通道:chan T
│ └── 函数:func
└── 接口类型(Interface Types)
├── interface{}(空接口,Go 1.18 前)
└── any(Go 1.18+ 空接口别名)
2026/3/20大约 14 分钟