From 85bb40721dd695d5d108b9bbc25ad7018fcb22d5 Mon Sep 17 00:00:00 2001 From: Dhawal Sanghvi <sanghvi.dhawal101433@gmail.com> Date: Fri, 10 Jan 2025 15:49:02 +0530 Subject: [PATCH] chore(featureflags): add README.md --- featureflags/README.md | 43 +++++++++++++++++++++++++++++++++ featureflags/example/example.go | 5 ++-- 2 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 featureflags/README.md diff --git a/featureflags/README.md b/featureflags/README.md new file mode 100644 index 00000000..c4b534cc --- /dev/null +++ b/featureflags/README.md @@ -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. \ No newline at end of file diff --git a/featureflags/example/example.go b/featureflags/example/example.go index c0432c2b..de8390f9 100644 --- a/featureflags/example/example.go +++ b/featureflags/example/example.go @@ -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) - }