Go 标识符和关键字

  1. 命名方式

    • 首字符可以是任意 Unicode 字符或下划线。
    • 首字符之外的部分是可以是 'Unicode' 字符、下划线或数字。
    • 名字的长度无限制(理论上名字里可以有汉字,甚至可以全是汉字,但实际中不要这么做)
  2. 关键字

    • 下列关键字在 go 语言中都是有特殊含义的,自己在写代码的时候禁止使用。
      break default func interface select case defer go map
      struct chan else goto package switch const if range
      type continue for import return fallthrough var
  3. 保留字

    • 常量
      true false iota nil
    • 数据类型
      int int8 int16 int32 int64 uint uint8 uint16 uint32
      uint64 uintptr float32 float64 complex128 complex64 bool
      byte rune string error
    • 函数
      make len cap new append copy close delete complex
      real imag panic recover
点赞

发表回复

电子邮件地址不会被公开。必填项已用 * 标注