TOC

Go 关键字

25 个关键字

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

声明 (4)

  1. var 变量
  2. const 常量
  3. type 类型
  4. func 函数

并发相关 (3)

  1. go 并发
  2. chan 信道
  3. select 分支

类型 (3)

  1. interface 接口
  2. map 映射
  3. struct 结构体

流程控制 (3 + 4 + 6)

  1. defer 延迟执行
  2. goto 跳转
  3. return 返回

循环 (4)

  1. for
  2. continue
  3. break
  4. range 用于读取 slice、map、channel 数据

分支 (6)

  1. if
  2. else
  3. switch
  4. case
  5. default
  6. fallthrough

包 (2)

  1. package
  2. import

39 个预定义标识符

Types:
    any bool byte comparable
    complex64 complex128 error float32 float64
    int int8 int16 int32 int64 rune string
    uint uint8 uint16 uint32 uint64 uintptr

Constants:
    true false iota

Zero value:
    nil

Functions:
    append cap close complex copy delete imag len
    make new panic print println real recover

值 (4)

  1. true
  2. false
  3. iota
  4. nil

类型 (20 + 2)

int (10)

  1. int
  2. int8
  3. int16
  4. int32
  5. int64
  6. uint
  7. uint8
  8. uint16
  9. uint32
  10. uint64

complex (2)

  1. complex64
  2. complex128

float (2)

  1. float32
  2. float64

字符与字符串 (3)

  1. byte => uint8
  2. rune => int32
  3. string

泛型相关 (2) Go1.18+

  1. any
  2. comparable

其他 (3)

  1. bool
  2. uintptr 指针
  3. error 一个内置的 interface

Builtin 函数 (15)

  1. append
  2. delete
  3. close

  4. cap

  5. len

  6. copy

  7. make

  8. new

  9. panic

  10. recover

  11. print

  12. println

  13. real

  14. imag
  15. complex