Go 语言中的函数名、变量名、常量名、类型名、语句标号和包名等所有的命名,都遵循一个简单的命名规则。
必须以一个字母或者下划线(_)开头,后面可以跟任意数量的字母、数字或下划线。
在 Go 语言中,大小写字母是不同的。
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
a := 1A := 1
以上要求是必须满足的,下面的要求要尽量做到
MyName := "Conan"myName := "Conan"
Go语言中的 37 个保留字:
Constants: true false iota nil
Types: int int8 int16 int32 int64
uint uint8 uint16 uint32 uint64 uintptr
float32 float64 complex128 complex64
bool byte rune string error
Functions: make len cap new append copy close delete
complex real imag
panic recover