@@ -3,6 +3,7 @@ package evaluation
3
3
import (
4
4
"fmt"
5
5
"reflect"
6
+ "strconv"
6
7
"strings"
7
8
8
9
"github.com/harness/ff-golang-server-sdk/log"
@@ -37,6 +38,27 @@ func getAttrValue(target *Target, attr string) reflect.Value {
37
38
return value
38
39
}
39
40
41
+ func reflectValueToString (val reflect.Value ) string {
42
+ stringValue := ""
43
+ switch val .Kind () {
44
+ case reflect .Int , reflect .Int64 :
45
+ stringValue = strconv .FormatInt (val .Int (), 10 )
46
+ case reflect .Bool :
47
+ stringValue = strconv .FormatBool (val .Bool ())
48
+ case reflect .String :
49
+ stringValue = val .String ()
50
+ case reflect .Array , reflect .Chan , reflect .Complex128 , reflect .Complex64 , reflect .Func , reflect .Interface ,
51
+ reflect .Invalid , reflect .Ptr , reflect .Slice , reflect .Struct , reflect .Uintptr , reflect .UnsafePointer ,
52
+ reflect .Float32 , reflect .Float64 , reflect .Int16 , reflect .Int32 , reflect .Int8 , reflect .Map , reflect .Uint ,
53
+ reflect .Uint16 , reflect .Uint32 , reflect .Uint64 , reflect .Uint8 :
54
+ stringValue = fmt .Sprintf ("%v" , val )
55
+ default :
56
+ // Use string formatting as last ditch effort for any unexpected values
57
+ stringValue = fmt .Sprintf ("%v" , val )
58
+ }
59
+ return stringValue
60
+ }
61
+
40
62
func findVariation (variations []rest.Variation , identifier string ) (rest.Variation , error ) {
41
63
for _ , variation := range variations {
42
64
if variation .Identifier == identifier {
0 commit comments