清水泥沙

golang基础(7.数据类型概述,以及布尔类型)

基本类型

作为静态语言,go有7种基础数据类型。

  • 布尔类型:bool
  • 整型:int8、byte、int16、int、uint、uintptr (有符号,无符号)
  • 浮点类型:float32、float64 (有符号,无符号)
  • 复数类型:complex64、complex128
  • 字符串:string
  • 字符类型:rune
  • 错误类型:error

在go中的整形以及浮点类型都区分有有符号以及无符号,即1,1.0(无符号)``-1,-1.9(有符号)。浮点类型通过,float 以及double 来区分精度。

复合类型

除去以上7种以为还支持多种复合类型

  • 指针(pointer)
  • 数组(array)
  • 切片(slice)
  • 字典(map)
  • 通道(chan)
  • 结构体(struct)
  • 接口(interface)