GO-05-数据类型

基本数据类型:

整型、浮点型 float32 float64、复数型(数学中的复数)、布尔型、字符串、字符(byte、rune)。

复合数据类型:

数组(array)、切片(slice)、映射(map)、函数(function)、结构体(struct)、通道(channel)、接口(interface)、指针(pointer)

整型分两大类:

有符号整型:int8、int16、int32、int64、int。

无符号整型:uint8、uint16、uint32、uint64、uint。

布尔型

GO语言中,bool只能是true或者false

var tag bool

bool 不能参与运行,也不能进行类型转化

字符串

双引号书写字符串被称为字符串字面量(string literal),这种字面量不能跨行。

多行字符串需要使用反引号“`”,多用于内嵌源码和内嵌数据。

字符

字符串中的一个元素,有两种类型,用单引号

byte:1字节

rune:4字节

var tmp byte ='a'

猜你喜欢

转载自www.cnblogs.com/shix0909/p/12963850.html