The flipt-client-go
directory contains the Go source code for the Flipt client-side evaluation client.
go get go.flipt.io/flipt-client
In your Go code you can import this client and use it as so:
package main
import (
"context"
"fmt"
"log"
flipt "go.flipt.io/flipt-client"
)
func main() {
evaluationClient, err := flipt.NewClient()
if err != nil {
log.Fatal(err)
}
defer evaluationClient.Close()
variantResult, err := evaluationClient.EvaluateVariant(context.Background(), "flag1", "someentity", map[string]string{
"fizz": "buzz",
})
if err != nil {
log.Fatal(err)
}
fmt.Println(*variantResult.Result)
}
The engine that is allocated on the Rust side to compute evaluations for flag state will not be properly deallocated unless you call the Close()
method on a Client
instance.
Please be sure to do this to avoid leaking memory!
defer evaluationClient.Close()