1. 行分隔符

在 Go 程序中,一行代表一个语句结束。如果你打算将多个语句写在同一行,它们则必须使用 ; 人为区分,但在实际开发中我们并不鼓励这种做法。

2. 注释

// 单行注释

/*
 多行注释
 */

3. 标识符命名规则

和C,Java等一样,一个标识符由一个或是多个字母、数字、下划线组成,但是第一个字符必须是字母或下划线不能是数字。

4. 关键字

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

除了上面的这些关键字,Go 语言还有 36 个预定义标识符:

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