- 在函数中,简洁赋值语句 := 可在类型明确的地方代替 var 声明。
- 函数外的每个语句都必须以关键字开始(var, func 等等),因此 := 结构不能在函数外使用。
- 为什么Go使用后置类型生命 https://blog.go-zh.org/gos-declaration-syntax
- Go的类型有如下:
bool
string
int int8 int16 int32 int64
uint uint8 uint16 uint32 uint64 uintptr
byte // uint8 的别名
rune // int32 的别名
// 表示一个 Unicode 码点
float32 float64
complex64 complex128
- 当你需要一个整数值时应使用 int 类型,除非你有特殊的理由使用固定大小或无符号的整数类型。
- Go不存在隐式转换