™技术博客

go | 语法篇02

2021年7月20日

基本数据类型

类型
bool
string
int int8 int16 int32 int64
uint uint8 uint16 uint32 uint64 uintptr
byte // alias for uint8
rune // alias for int32, represetns a Unicode code point
float32 float64
complex64 complex128

类型转换

  • Go语言不允许隐式类型转换
  • 别名和原有类型也不能进行隐式类型转换

类型的预定义值

  • math.MaxInt64
  • math.MaxFloat64
  • math.MaxUint32

指针类型

  • 不支持指针运算
  • string是值类型,其默认的初始化值为空字符串,而不是nil
Tags: go

扫描二维码,分享此文章