configcat

module
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 12, 2024 License: Apache-2.0

README

ConfigCat OpenFeature provider for Go

OpenFeature Go provider implementation for ConfigCat that uses the official ConfigCat Go SDK.

Installation

# ConfigCat SDK
go get github.com/configcat/go-sdk/v7

# OpenFeature SDK
go get github.com/open-feature/go-sdk/openfeature
go get github.com/open-feature/go-sdk-contrib/providers/configcat

Usage

Here's a basic example:

import (
	"context"
	"fmt"

	sdk "github.com/configcat/go-sdk/v7"
	configcat "github.com/open-feature/go-sdk-contrib/providers/configcat/pkg"
	"github.com/open-feature/go-sdk/openfeature"
)

func main() {
	provider := configcat.NewProvider(sdk.NewClient("..."))
	openfeature.SetProvider(provider)

	client := openfeature.NewClient("app")

	val, err := client.BooleanValue(context.Background(), "flag_name", false, openfeature.NewEvaluationContext("123", map[string]any{
		configcat.EmailKey: "test@example.com",
	}))
	fmt.Printf("val: %+v - error: %v\n", val, err)
}

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL