2.1 普通类型:

  • bool
  • int(32 or 64), int8, int16, int32, int64
  • uint(32 or 64), uint8(byte), uint16, uint32, uint64
  • float32, float64
  • string
  • complex64, complex128
  • array

官方文档:int is a signed integer type that is at least 32 bits in size. It is a distinct type, however, and not an alias for, say, int32.

int整形最少占32位,int和int32是两码事

complex:复数类型

可以存储两个数值:real、image

实数部分和虚数部分都是[float32]类型

可以通过real(complex)拿到real值,同理可以通过imag(complex)拿到image值

例如:

func main() {
   c := complex(11.11, 22.22)
   fmt.Printf("%f\n%f", real(c), imag(c))
}

输出为:

11.110000
22.220000

array为固定长度