go 基础语法

  • 行分隔符:一行就是一个语句;多个语句放一行需要手动加;,但是不建议
  • 注释不被编译,但是建议每个包一个注释
  • 标识符:用于命名变量、类型等程序实体,以字母或下划线开头
  • 关键字,25 个
    • break, case, chan, const, continue
    • default, defer, else, fallthrough, for
    • func, go, goto, if, import
    • interface, map, package, range, return
    • select, struct, switch, type, var
  • 预定义标识符,36 个
    • append, bool, byte, cap, close, complex
    • complex64, complex128, copy, false, float32, float64
    • imag, int, int8, int16, int32, int64
    • iota, len, make, new, nil, panic
    • print, println, real, recover, string, true
    • uint, uint8, uint16, uint32, unit64
  • 空格:变量声明需要空格隔开;适当空格增加易阅读性

相关