Skip to content

wingify/vwo-openfeature-provider-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

VWO OpenFeature Provider Go

License

Overview

VWO OpenFeature Provider Go is an implementation of the OpenFeature Provider interface for VWO. This library allows you to use VWO as a feature flag and experimentation provider in applications that leverage the OpenFeature standard.

With this provider, you can:

  • Evaluate feature flags and variables using OpenFeature's standardized SDK APIs.
  • Integrate VWO flag and experiment management seamlessly into your Go applications.

Requirements

Go language version: 1.24

Getting started

Install

Add the provider to your module:

go get github.com/wingify/vwo-openfeature-provider-go

Basic Usage

package main

import (
    "context"
    "fmt"
    "log"

    "github.com/open-feature/go-sdk/openfeature"
    vwo "github.com/wingify/vwo-openfeature-provider-go/pkg"
)

func main() {
    provider, err := vwo.NewVWOProviderWithConfig(map[string]interface{}{
        "sdkKey":    "<your-vwo-sdk-key>",
        "accountId": "<your-vwo-account-id>",
    })
    if err != nil {
        log.Fatalf("Failed to create VWO feature provider: %v", err)
    }

    openfeature.SetProviderAndWait(provider)
    client := openfeature.NewClient("my-app")

    // Evaluate a boolean flag. If no variableKey is provided, this returns flag enabled/disabled.
    ctx := openfeature.NewEvaluationContext("unique-user-id", map[string]any{"variableKey": "booleanVariableKey"})
    enabled, err := client.BooleanValue(context.Background(), "featureKey", false, ctx)
    if err != nil {
        log.Fatalf("Failed to get boolean value: %v", err)
    }
    fmt.Println("Enabled:", enabled)

    // Evaluate typed variables by passing variableKey in the evaluation context
    // String variable
    ctx = openfeature.NewEvaluationContext("unique-user-id", map[string]any{"variableKey": "stringVariableKey"})
    strVal, _ := client.StringValue(context.Background(), "featureKey", "default", ctx)
    fmt.Println("String value:", strVal)

    // Integer variable
    ctx = openfeature.NewEvaluationContext("unique-user-id", map[string]any{"variableKey": "integerVariableKey"})
    intVal, _ := client.IntValue(context.Background(), "featureKey", 0, ctx)
    fmt.Println("Int value:", intVal)

    // Float variable
    ctx = openfeature.NewEvaluationContext("unique-user-id", map[string]any{"variableKey": "floatVariableKey"})
    floatVal, _ := client.FloatValue(context.Background(), "featureKey", 0.0, ctx)
    fmt.Println("Float value:", floatVal)

    // JSON variable
    ctx = openfeature.NewEvaluationContext("unique-user-id", map[string]any{"variableKey": "jsonVariableKey"})
    jsonVal, _ := client.ObjectValue(context.Background(), "featureKey", map[string]any{}, ctx)
    fmt.Println("JSON value:", jsonVal)
}

Notes

  • Evaluation context targetingKey: Provide a stable user identifier as the first argument to openfeature.NewEvaluationContext(...). The provider maps this to VWO's id for audience targeting and deterministic bucketing.
  • variableKey: Provide variableKey in the context to fetch a particular variable’s value. If omitted for boolean evaluations, the provider returns the flag’s enabled/disabled state.
  • Supported variable types: boolean, string, integer, float, and json.

Changelogs

Refer CHANGELOG.md

Contributing

Please go through our contributing guidelines

Code of Conduct

Code of Conduct

License

Apache License, Version 2.0

Copyright 2025 Wingify Software Pvt. Ltd.

About

OpenFeature Provider for VWO FE Go SDK

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

No packages published

Languages