Skip to content

Go onboarding incorrect code example on us.posthog.com #114

@iammuhammedabdAllah

Description

@iammuhammedabdAllah
package main

import (
    "github.com/posthog/posthog-go"
)

func main() {
    client, _ := posthog.NewWithConfig("my-secret", posthog.Config{Endpoint: "https://us.i.posthog.com"})
    defer client.Close()

    isMyFlagEnabledForUser, err := client.IsFeatureEnabled(
    FeatureFlagPayload{
        Key:        'my-flag',
        DistinctId: "distinct-id",
    })

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

}
  1. FeatureFlagPayload would be posthog.FeatureFlagPayload
    posthog.FeatureFlagPayload{

  2.    Key:        "my-flag",  // double quotes
     DistinctId: "distinct-id",
    

    })

  3. client.IsFeatureEnabled doesn't return boolean, it returns interface and error

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions