Go SDK
Thread-safe client for evaluating feature flags in Go applications.
Installation
bash
go get github.com/featuresignals/sdk-goRequirements: Go 1.22+
Quick Start
go
package main
import (
"fmt"
fs "github.com/featuresignals/sdk-go"
)
func main() {
client := fs.NewClient("fs_srv_your_api_key", "production",
fs.WithBaseURL("https://api.featuresignals.com"),
)
defer client.Close()
<-client.Ready()
ctx := fs.NewContext("user-123").
WithAttribute("country", "US").
WithAttribute("plan", "enterprise")
enabled := client.BoolVariation("new-feature", ctx, false)
fmt.Println("Feature enabled:", enabled)
}Configuration Options
| Option | Default | Description |
|---|---|---|
WithBaseURL | https://api.featuresignals.com | API server URL |
WithPollingInterval | 30s | Flag refresh interval |
WithSSE | false | Use SSE instead of polling |
WithLogger | slog.Default() | Structured logger |
Variation Methods
go
// Boolean
enabled := client.BoolVariation("flag-key", ctx, false)
// String
theme := client.StringVariation("theme", ctx, "light")
// Number (returns float64)
limit := client.NumberVariation("rate-limit", ctx, 100.0)
// JSON (returns interface{})
config := client.JSONVariation("feature-config", ctx, map[string]interface{}{})