2019-01-07 14:28:24 +00:00
|
|
|
package reflect
|
|
|
|
|
|
|
|
import (
|
|
|
|
"reflect"
|
|
|
|
)
|
|
|
|
|
|
|
|
func Indirect(v interface{}) interface{} {
|
|
|
|
if v == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return IndirectValue(reflect.ValueOf(v)).Interface()
|
|
|
|
}
|
|
|
|
|
2019-01-07 14:35:34 +00:00
|
|
|
func IndirectValue(reflectValue Value) Value {
|
2019-01-07 14:28:24 +00:00
|
|
|
if reflectValue.Kind() == reflect.Ptr {
|
|
|
|
return reflectValue.Elem()
|
|
|
|
}
|
|
|
|
return reflectValue
|
|
|
|
}
|
|
|
|
|
2019-01-07 14:35:34 +00:00
|
|
|
func IndirectType(reflectType Type) Type {
|
2019-01-07 14:28:24 +00:00
|
|
|
if reflectType == TypeInvalid {
|
|
|
|
return TypeInvalid
|
|
|
|
}
|
|
|
|
|
|
|
|
if reflectType.Kind() == reflect.Ptr {
|
|
|
|
return reflectType.Elem()
|
|
|
|
}
|
|
|
|
return reflectType
|
|
|
|
}
|