类型 | 名称 | 长度 | 零值 | 说明 |
---|---|---|---|---|
bool | 布尔类型 | 1 | false | 其值不为真即为假,不可以用数字代表true或false |
byte | 字节型 | 1 | 0 | uint8别名 |
rune | 字符类型 | 4 | 0 | 专用于存储unicode编码,等价于uint32 |
int, uint | 整型 | 4或8 | 0 | 有符号32位或无符号64位 |
int8 | 整型 | 1 | 0 | -128 ~ 127, |
uint8 | 整型 | 1 | 0 | 0 ~ 255 |
int16 | 整型 | 2 | 0 | -32768 ~ 32767, |
uint16 | 整型 | 2 | 0 | 0 ~ 65535 |
int32 | 整型 | 4 | 0 | -2147483648 到 2147483647 |
uint32 | 整型 | 4 | 0 | 0 到 4294967295(42亿) |
int64 | 整型 | 8 | 0 | 0 到 18446744073709551615(1844京) |
uint64 | 整型 | 8 | 0 | -9223372036854775808到 9223372036854775807 |
float32 | 浮点型 | 4 | 0.0 | 小数位精确到7位 |
float64 | 浮点型 | 8 | 0.0 | 小数位精确到15位 |
complex64 | 复数类型 | 8 | ||
complex128 | 复数类型 | 16 | 64 | 位实数和虚数 |
uintptr | 整型 | 4或8 | ⾜以存储指针的uint32或uint64整数 | |
string | 字符串 | “” | utf-8字符串 |