Skip to main content
The Confidence Go SDK provides ultra-low latency feature flag evaluation for Go applications using the Confidence Resolver—a Rust-based resolver that runs natively or as WebAssembly.

Features

  • Local evaluation: Flag rules evaluate on your infrastructure in microseconds
  • OpenFeature compatible: Standard feature flag API through OpenFeature provider
  • Background sync: Flag rules and logging sync with Confidence in the background
  • High reliability: No network dependency at evaluation time

Installation

go get github.com/spotify/confidence-resolver/openfeature-provider/go
go mod tidy

Quickstart

package main

import (
    "context"
    "log"

    "github.com/open-feature/go-sdk/openfeature"
    "github.com/spotify/confidence-resolver/openfeature-provider/go/confidence"
)

func main() {
    ctx := context.Background()

    // Initialize the Confidence provider
    provider, err := confidence.NewProvider(ctx, confidence.ProviderConfig{
        ClientSecret: "your-client-secret",
    })
    if err != nil {
        log.Fatalf("Failed to create provider: %v", err)
    }

    // Register with OpenFeature
    openfeature.SetProviderAndWait(provider)
    client := openfeature.NewClient("my-app")

    // Evaluate a flag
    evalCtx := openfeature.NewEvaluationContext("user-123", map[string]interface{}{
        "country": "US",
    })

    value, err := client.BooleanValue(ctx, "my-feature-flag.enabled", false, evalCtx)
    if err != nil {
        log.Printf("Flag evaluation failed: %v", err)
    }
    log.Printf("Flag value: %v", value)
}

Resources