86193d253b
This reverts commit c06889aa8c
32 lines
542 B
Go
32 lines
542 B
Go
package reflect
|
|
|
|
import (
|
|
"reflect"
|
|
)
|
|
|
|
func Indirect(v interface{}) interface{} {
|
|
if v == nil {
|
|
return nil
|
|
}
|
|
|
|
return IndirectValue(reflect.ValueOf(v)).Interface()
|
|
}
|
|
|
|
func IndirectValue(reflectValue reflect.Value) reflect.Value {
|
|
if reflectValue.Kind() == reflect.Ptr {
|
|
return reflectValue.Elem()
|
|
}
|
|
return reflectValue
|
|
}
|
|
|
|
func IndirectType(reflectType reflect.Type) reflect.Type {
|
|
if reflectType == TypeInvalid {
|
|
return TypeInvalid
|
|
}
|
|
|
|
if reflectType.Kind() == reflect.Ptr {
|
|
return reflectType.Elem()
|
|
}
|
|
return reflectType
|
|
}
|