full-pager-39100
06/22/2023, 6:05 PMversion equal 10
context := growthbook.NewContext().
WithFeatures(featureMap).
WithAttributes(growthbook.Attributes{
"version": 10,
})
gb := growthbook.New(context)
value := gb.Feature("featureName").Value
fresh-football-47124
full-pager-39100
06/23/2023, 12:32 AMv0.1.0
does v0.1.3
have the fix?fresh-football-47124
better-magician-65629
07/04/2023, 6:18 PMalert-dream-63361
07/04/2023, 7:26 PM"version": 10
and "version": { "$eq": 10 }
both seem to work fine.
This might be a stupid question, but does the conditional value appear as an integer in the feature rule definition? If the condition is coming through as "version": "10"
, then the Go SDK code won't work, because it requires the two values being compared to be the same type. String vs. int comparisons might be something we should be able to handle though, because I think the JS code will just quietly convert strings to ints for conversion there. What do you think, @better-magician-65629?better-magician-65629
07/04/2023, 8:00 PMdonut_price
is an example of a float doing that. https://cdn.growthbook.io/api/features/java_NsrWldWd5bxQJZftGsWKl7R2yD2LtAK8C8EUYh9L8
in the java SDK, what i'm doing to get around the types thing is, in one case, i am getting number types as float, and coercing the attribute to a float if it's a number type, and checking those. in another case, the JSON serialization library i'm using (gson) has a way to get the JSON primitive as a Number which supports equality checks across numeric types.
@alert-dream-63361 not sure if it may be worth the effort to take a look at the go example and do some equality checks with the donut_price
feature. i realized i didn't grab that attribute but it's there in the response (it's using the java_N.. url linked above)alert-dream-63361
07/04/2023, 9:03 PMbetter-magician-65629
07/04/2023, 9:27 PMalert-dream-63361
07/05/2023, 11:44 AMcontext := growthbook.NewContext().
WithFeatures(featureMap).
WithAttributes(growthbook.Attributes{
"version": float64(10),
})
gb := growthbook.New(context)
value := gb.Feature("featureName").Value
That will make the comparisons with the numeric values coming from the GrowthBook API work correctly.better-magician-65629
07/05/2023, 4:50 PMwhich matches the semantics of the JS SDKdid you mean the java SDK? the JS SDK didn't have this challenge. but yeah, that's what i described above, so i think that should work for go as well.
alert-dream-63361
07/05/2023, 6:34 PMbetter-magician-65629
07/05/2023, 8:06 PM