Skip to main content

Flagmint Go SDK

The Flagmint Go SDK is a high-performance, type-safe client for evaluating feature flags in Go applications. It features flexible caching strategies, real-time updates, and efficient local evaluation.

Quick Start

Get up and running in minutes

Configuration

Customize SDK behavior

Local Evaluation

Evaluate flags locally

Caching

Configure caching strategies

Transport

WebSocket and polling

Key Features

  • High Performance — Optimized for server-side flag evaluation
  • Local Evaluation — Evaluate flags without making network requests
  • Flexible Caching — Built-in in-memory cache with customizable options
  • Real-time Updates — WebSocket support with automatic fallback
  • Type-Safe — Full Go typing with clear error handling
  • Production Ready — Battle-tested in high-throughput environments

Installation

go get github.com/flagmint/flagmint-go

Quick Example

package main

import (
    "context"
    "log"
    "time"

    flagmint "github.com/flagmint/flagmint-go"
)

func main() {
    client, err := flagmint.NewClient("fm_sdk_your_api_key",
        flagmint.WithContext(flagmint.EvaluationContext{
            Kind: "user",
            Key:  "user-123",
            Attributes: map[string]any{
                "country": "DE",
                "plan":    "pro",
            },
        }),
    )
    if err != nil {
        log.Fatal(err)
    }
    defer client.Close()

    // Wait for flags to load
    ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
    defer cancel()
    
    if err := client.WaitForReady(ctx); err != nil {
        log.Fatal(err)
    }

    // Evaluate a flag
    value, err := client.Evaluate("my-feature-flag")
    if err != nil {
        log.Fatal(err)
    }

    log.Printf("Flag value: %v", value)
}

Next Steps