PostHog / posthog-go

Official PostHog Go library
MIT License
20 stars 17 forks source link

Why does `IsFeatureEnabled` return `interface{}`? #27

Closed zaynetro closed 6 months ago

zaynetro commented 7 months ago

Is there a reason why IsFeatureEnabled returns interface{} and not bool?

Your docs suggest using the library the following way:

isMyFlagEnabled, err := client.IsFeatureEnabled(
            FeatureFlagPayload{
                Key:        "flag-key",
                DistinctId: "distinct_id_of_your_user",
            })

if isMyFlagEnabled {
    // Do something differently for this user
}

With interface{} return value it is not possible.

-if isMyFlagEnabled {
+if isMyFlagEnabled == true {

Could you update the code or the docs?

neilkakkar commented 6 months ago

Thanks @zaynetro , updating the docs 👍 , I think it's an interface right now because it can pass in nil as well 🤔

zaynetro commented 6 months ago

Oh you are totally right. Thanks!