# 新概念
comparable
官方解释: the
comparableconstraint is predeclared in Go. It allows any type whose values may be used as an operand of the comparison operators==and!=.可比较的类型
any
官方解释:
anyis an alias for interface{} and is equivalent to interface{} in all ways.等同于 interface{}
constraint
类型约束声明为接口. For example:
type Number interface { int64 | float64 }type Number interface { ~int64 | ~float64 // ~ 表示所有的 int64, float64, 即用户自定义的别名 }
# 源码
# 参考资料
← cobra 终极指南 slice 范型使用 →