Madhawa
Madhawa

Reputation: 147

How to read Treatment values from split GO SDK

My split.io feature flag is sky_name

feature flag has following treatment { "sk_price":"45788" }

I want to read sk_price when treatment is on.

My sample code is as below

import (
    "github.com/splitio/go-client/v6/splitio/client"
    "github.com/splitio/go-client/v6/splitio/conf"
)

func main() {
    cfg := conf.Default()
    factory, err := client.NewSplitFactory("YOUR_SDK_TYPE_API_KEY", cfg)
    if err != nil {
        
    }

    client := factory.Client()

    err = client.BlockUntilReady(10)
    if err != nil {
       
    }

    treatment := client.Treatment("CUSTOMER_ID", "sky_name", nil)
    if treatment == "on" {

// I want to get the "sk_price" value here when the treatment is on

    } else if treatment == "off" {
        
    } else {
       
    }
}

Upvotes: 2

Views: 107

Answers (0)

Related Questions