funcmain(){var(
a int=16
b int32=32)
b = a // 报错:cannot use b (type int32) as type int in assignmentprint(a + b)// 报错:invalid operation: a + b (mismatched types int and int32)}
浮点型
注意:没有float类型
Type
Length
Default Value
Extra
float32
4
0.0
float64
8
0.0
即便在32 位的架构上也是 64位的
字符串
Type
Length
Default Value
Extra
string
“”
类似使用UTF-8字符的字节数组
var(
a string="abc\ndef"// \n被转义
b string=`abc\ndef`// \n被原样输出)print(a, b)