One - One Code All

Blog Content

go语言类型:基础类型和复合类型,在一个数组中存放不同类型的数据

Go   2013-10-19 22:11:13

Go 语言中包括以下内置基础类型:
布尔型:bool
整型:int int64 int32 int16 int8 uint8(byte) uint16 uint32 uint64 uint
浮点型:float32 float64
复数型:complex64 complex128
字符串:string
字符型:rune
错误型:error

Go 语言中包括以下内置复合类型:

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


如何在一个数组中存放不同类型的数据?

go是强类型语言,但任何类型都可以转为interfalce{}类型。 所以用 []interface{}。



上一篇:postgresql开启归档日志
下一篇:Go语言二维数组的2种遍历方式

The minute you think of giving up, think of the reason why you held on so long.