Go SDK
Gov1.6.3
Terminal window
Installation
Section titled “Installation”go get github.com/flags-gg/go-flagsQuick Start
Section titled “Quick Start”package main
import ( "fmt" flags "github.com/flags-gg/go-flags")
func main() { client := flags.NewClient( flags.WithAuth(flags.Auth{ ProjectID: "your-project-id", AgentID: "your-agent-id", EnvironmentID: "your-environment-id", }), )
if client.Is("new-feature").Enabled() { fmt.Println("Feature is enabled!") }}Listing Flags
Section titled “Listing Flags”allFlags, err := client.List()if err != nil { log.Fatal(err)}
for _, flag := range allFlags { fmt.Printf("%s: %v\n", flag.Details.Name, flag.Enabled)}Batch Operations
Section titled “Batch Operations”Check several flags in a single call:
// Returns map[string]bool of flag name to enabled statusresults := client.GetMultiple("feature-1", "feature-2", "feature-3")
// Returns true only if every named flag is enabledif client.AllEnabled("feature-1", "feature-2") { fmt.Println("All features enabled")}
// Returns true if any named flag is enabledif client.AnyEnabled("premium", "beta") { fmt.Println("At least one feature enabled")}Background Refresh
Section titled “Background Refresh”Opt in to background refresh so flag lookups never block on the network. Always call Close() to stop the goroutine when the client is no longer needed:
client := flags.NewClient( flags.WithAuth(auth), flags.WithBackgroundRefresh(),)defer client.Close()