gitlab.com/evatix-go/core@v1.3.55/coredata/coredynamic/PointerOrNonPointerUsingReflectValue.go (about) 1 package coredynamic 2 3 import "reflect" 4 5 func PointerOrNonPointerUsingReflectValue( 6 isPointerOutput bool, 7 rv reflect.Value, 8 ) (output interface{}, finalReflectVal reflect.Value) { 9 k := rv.Kind() 10 11 if !isPointerOutput && (k == reflect.Ptr || k == reflect.Interface) { 12 finalReflectVal = rv.Elem() 13 14 return finalReflectVal.Interface(), finalReflectVal 15 } 16 17 if isPointerOutput && k != reflect.Ptr { 18 val := finalReflectVal.Interface() 19 20 return &val, rv 21 } 22 23 // struct or value 24 return rv.Interface(), rv 25 }