go语言学习之路 二:变量
说道变量,首先应该提一提关键字,因为不能把关键字当做变量来声明。 关键字: 下面列出GO语言的关键字或保留字: 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 这些关键字和保留字不需要特意去记,先走马观花看看,在以后的编程过程中会反复看到这些身影。 变量 声明变量的一般形式是使用 var 关键字:var identifier type。需要注意的是,Go 和许多编程语言不同