go的类型别名 不能和他本来的类型相加,报错 invalid operation: a + b (mismatched types bigint and int64)

点击查看代码
package main

import "fmt"

func main() {
	// 比如int64,我想改成bigint
	type bigint int64
	var a bigint
	a = 10
	fmt.Println(a)
	
	fmt.Printf("%T\n",a)  // main.bigint main包.bigint
	

	/* 	//类型别名不能和他本来的类型相加,报错 invalid operation: a + b (mismatched types bigint and int64)
	var b int =77
	c :=a +b
	fmt.Printf("%T\n",c)  // main.bigint main包.bigint
	fmt.Printf("%d\n",c)  // main.bigint main包.bigint  */
}

posted @ 2022-02-28 12:30  ty1539  阅读(452)  评论(0编辑  收藏  举报