根本数据类型

Go 语音不容许隐式类型转换,也不容许别名类型和原类型进行隐式类型转换。

boolstringint int8 int16 int32 int64uint uint8 uint16 uint32 uint64byte // alias for uint8rune // alias for int32float32 float64complex64 complex128
package type_testimport (    "fmt") //引入代码依赖type MyInt int64  // 定义别名func TestConstant0(t *testing.T) {    var a int = 1    var b int32 = 1    var c int64    c = a  // 不反对    c = b  // 不反对    c = int64(a)  // 反对    c = int64(b)  // 反对        var d MyInt    d = MyInt(b)        t.Log(a, b, c, b)}

类型的预约义值

math.MaxInt64math.MaxFloat64math.MaxUint32