摘要:
类型定义是在当前包中的一直存在的.输出%T,发现类型前面都有main.前缀 类型别名,其实还是它的根本类型,别名只存在在代码中.编译后就不存在了,还是根本类型. 阅读全文
posted @ 2020-05-28 19:34
菜鸟++
阅读(332)
评论(0)
推荐(0)
摘要:
所以定义其他包的别名类型,通常会导致报错: type Talias = 其他包.T cannot define new methods on non-local type time.Duration 对于其他包中的类型,本地若想使用 可以在本地重新定义个自定义类型 type myT 其他包.T 阅读全文
posted @ 2020-05-28 19:30
菜鸟++
阅读(669)
评论(0)
推荐(0)
摘要:
命名类型:一个命名类型一定跟其他类型不同. 哪些是命名类型 1. 预先声明的类型,如int/int8/boo/float32... 2.使用type声明的类型,类似起别名,如type aInt int var i int // named type type myInt int // named t 阅读全文
posted @ 2020-05-28 19:06
菜鸟++
阅读(851)
评论(0)
推荐(0)
摘要:
预先类型: int/int8/bool/string ... 未命名类型:map[string]string []int [][]string 阅读全文
posted @ 2020-05-28 18:25
菜鸟++
阅读(240)
评论(0)
推荐(0)
摘要:
type switchs用法 这里存在一个未知类型变量的内省操作(introspection operation),就是x.(type),其中x是interface{}类型 阅读全文
posted @ 2020-05-28 11:34
菜鸟++
阅读(520)
评论(0)
推荐(0)
浙公网安备 33010602011771号