前言
github.com/google/cel-go/common/types/ref
type Val interface {
ConvertToNative(typeDesc reflect.Type) (interface{}, error)
ConvertToType(typeValue Type) Val
Equal(other Val) Val
Type() Type
Value() interface{}
}
当我们实现了一个interface时,使用swtich case去判断,会命中哪条结果?
switch i := v.(type) {
case ref.Val:
return resolveType(i.Value())
case *CustomType:
return resolveType(i.Value())
default:
}
经过测试发现,谁的case靠前,会命中谁,哪怕CustomType有一些私有方法
后面空了看看switch 底层实现。。