命名类型和未命名类型和基础类型

命名类型:一个命名类型一定跟其他类型不同.

哪些是命名类型

1. 预先声明的类型,如int/int8/boo/float32...

2.使用type声明的类型,类似起别名,如type aInt int

var i int // named type
type myInt int // named type
var b bool // named type

未命名类型:复杂数据类型都是未命名类型.

[]string // unnamed type
map[string]string // unnamed type
[10]int // unnamed type

基础类型:查找基础类型,最终递归到命名类型或未命名类型.

如果T 是预先声明类型:boolean, numeric, or string(布尔,数值,字符串)中的一个,或者是一个类型字面量(type literal),他们对应的基础类型就是T自身。

否则,T的基础类型就是 T所引用的那个类型的类型声明(type declaration)。



原文地址:https://www.cnblogs.com/keystone/p/12983247.html