gitlab.com/evatix-go/core@v1.3.55/coredata/coredynamic/ReflectInterfaceVal.go (about)

     1  package coredynamic
     2  
     3  import "reflect"
     4  
     5  // ReflectInterfaceVal
     6  //
     7  // Reduce pointer to value (one step only)
     8  func ReflectInterfaceVal(any interface{}) interface{} {
     9  	rVal := reflect.ValueOf(any)
    10  	k := rVal.Kind()
    11  
    12  	if k != reflect.Ptr && k != reflect.Interface {
    13  		return rVal.Interface()
    14  	}
    15  
    16  	if k == reflect.Ptr || k == reflect.Interface {
    17  		return rVal.Elem().Interface()
    18  	}
    19  
    20  	return rVal.Interface()
    21  }