Skip to content

Latest commit

 

History

History

flipt-client-go

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Flipt Client Go

Client tag Go Reference

The flipt-client-go directory contains the Go source code for the Flipt client-side evaluation client.

Installation

go get go.flipt.io/flipt-client

Usage

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)
}

Memory Management

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()