1.go的函数、变量、常量、自定义类型、包(package)的命名方式遵循以下规则
1、首字符可以是任意的unicode 字符或者下划线
2、剩余字符可以是unicode字符、下划线、数字
3、字符长度不限
2.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
3.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
4.可见性
1、声明在函数内部,是函数的本地值,类似private
2、声明在函数外部,是对当前包可见(包内所有.go文件都可见)的全局值,类似protect
3、声明在函数外部且首字母大写是所有包可见的全局值,类似public
go语言命名
最新推荐文章于 2023-07-10 23:38:12 发布