gochang

Go语言中的常量使用关键字 const 定义,常量类型:布尔型、数字型(整数型、浮点型和复数)和字符串

1、const name [type] = value  (类型说明符 [type]可以省略)

2、使用 const 常量的 iota 来模拟枚举类型

3、%d、%s、%b 、%T (十进制、字符型、二进制、类型别名)

4、类型别名

  1. // 将int取一个别名叫IntAlias
  2. type IntAlias = int

5、保留关键字

break default  func interface select
case defer go map struct
chan else goto package switch
const fallthrough if range type
continue for import return var

6、特殊的标识符

append bool byte cap close complex complex64 complex128 uint16
copy false float32 float64 imag int int8 int16 uint32
int32 int64 iota len make new nil panic uint64
print println real recover string true uint uint8 uintptr

猜你喜欢

转载自www.cnblogs.com/oceanran/p/12160735.html