Skip to content

Commit

Permalink
chore(featureflags): add README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
dhawal1248 committed Jan 10, 2025
1 parent 6d22209 commit 85bb407
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 3 deletions.
43 changes: 43 additions & 0 deletions featureflags/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

# Feature Flags Package

A Go package for managing feature flags using Flagsmith as the provider.

## Prerequisites

Before using this package, ensure you have set the following environment variable:

```bash
export FLAGSMITH_SERVER_SIDE_ENVIRONMENT_KEY=your-api-key
```

## Usage Example

Here's a basic example of how to use the feature flags package:

```go
package main

import (
"fmt"
"log"

"github.com/rudderlabs/rudder-go-kit/featureflags"
)

func main() {
// Set default traits (optional)
featureflags.SetDefaultTraits(map[string]string{
"exampleTrait": "exampleTraitValue",
})

// Check if a feature is enabled
isEnabled, err := featureflags.IsFeatureEnabled("testWs", "testFeature")
if err != nil {
log.Fatal(err)
}
fmt.Println(isEnabled)
}
```

For more detailed examples and implementation details, refer to the example directory.
5 changes: 2 additions & 3 deletions featureflags/example/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ import (
)

func main() {
featureflags.SetDefaultTraits(map[string]string{"tier": "ENTERPRISE_V1"})
isenabled, err := featureflags.IsFeatureEnabled("entTest", "enterpriseonlyfeature")
featureflags.SetDefaultTraits(map[string]string{"exampleTrait": "exampleTraitValue"})
isenabled, err := featureflags.IsFeatureEnabled("testWs", "testFeature")
if err != nil {
log.Fatal(err)
}
fmt.Println(isenabled)

}

0 comments on commit 85bb407

Please sign in to comment.