Skip to content

Feature flags in Go: SDKs compared, embedded flags and OpenFeature

How to use feature flags in Go: modules, minimum Go versions and evaluation modes for 15 SDKs, tested code for GO Feature Flag embedded in a Go service and for OpenFeature with flagd, plus context and shutdown advice.

5 min read

Short answer: Most Go flag SDKs download the rules and evaluate flags in your process, refreshed in the background. Go also has an option most languages don't: GO Feature Flag can run as a library inside your service, reading flags from a file in Git, S3 or Kubernetes with no flag server at all. Check each module's minimum Go version: several now require Go 1.25 or 1.26.

Which Go SDKs are there, and how do they evaluate?

Module versions and minimum Go versions from the Go module proxy, evaluation modes from each vendor's docs, checked on 15 November 2026.

Tool Module Minimum Go How the Go SDK evaluates
OpenFeature github.com/open-feature/go-sdk v1.20.0 1.26 Depends on the provider
LaunchDarkly github.com/launchdarkly/go-server-sdk/v7 v7.22.0 1.25 Locally, with the ruleset streamed
Unleash github.com/Unleash/unleash-go-sdk/v6 v6.5.1 1.23 Locally, refreshing every 15 seconds by default
GrowthBook github.com/growthbook/growthbook-golang v0.7.0 1.22 Locally, from cached feature definitions
Flagsmith github.com/Flagsmith/flagsmith-go-client/v5 v5.5.0 1.25 Remotely by default; local evaluation is opt-in and refreshes every 60 seconds
ConfigCat github.com/configcat/go-sdk/v9 v9.1.0 1.23 Locally, from a config polled every 60 seconds by default
PostHog github.com/posthog/posthog-go v1.44.1 1.21 Remotely by default; local evaluation polls every 5 minutes in Go
Statsig github.com/statsig-io/statsig-go-core v0.24.2 (the legacy SDK is statsig-io/go-sdk) 1.24 Locally after initialization
DevCycle github.com/devcyclehq/go-server-sdk/v2 v2.25.1 1.25 Locally by default, polling every 10 seconds; cloud bucketing optional
Split / Harness FME github.com/splitio/go-client/v6 v6.10.0 1.18 Locally, with changes pushed or polled
Optimizely github.com/optimizely/go-sdk/v2 v2.7.0 1.21 Locally, from a synced datafile
FeatBit github.com/featbit/featbit-go-sdk v1.1.3 1.13 Locally, with changes over WebSocket
Flipt go.flipt.io/flipt-client v1.6.0 1.26 Locally with a WASM engine run by Wazero (no cgo), polling every 120 seconds by default
GO Feature Flag github.com/thomaspoignant/go-feature-flag v1.58.1 1.26.10 In process, as a library or behind its relay proxy
flagd github.com/open-feature/go-sdk-contrib/providers/flagd v0.8.0 1.26 Remote over gRPC, in-process, or from a local file

Sources: the tool profiles list evaluation modes with sources; Go details from Unleash Go, Flagsmith server-side SDKs, PostHog local evaluation, Statsig Go Core and its legacy Go SDK page, DevCycle Go, Flipt Go client, GO Feature Flag Go module. Minimum versions are the go lines in each module's go.mod on proxy.golang.org.

How do I embed flags in a Go service without a flag server?

GO Feature Flag's Go module evaluates flags inside your process from a configuration file it polls. We built and ran this with GO Feature Flag v1.58.1 on Go 1.26.11. Its go.mod requires Go 1.26.10: Go 1.25 with GOTOOLCHAIN=local, as in the official Docker images, refused it, while with the default GOTOOLCHAIN=auto, Go downloads 1.26.10 and raises your module's go line (Go toolchains):

package main

import (
	"context"
	"fmt"
	"log"
	"net/http"
	"os"
	"os/signal"
	"syscall"
	"time"

	ffclient "github.com/thomaspoignant/go-feature-flag"
	"github.com/thomaspoignant/go-feature-flag/ffcontext"
	"github.com/thomaspoignant/go-feature-flag/retriever/fileretriever"
)

func main() {
	err := ffclient.Init(ffclient.Config{
		PollingInterval: 10 * time.Second, // the default is 60 seconds
		Context:         context.Background(),
		Retriever:       &fileretriever.Retriever{Path: "flags.yaml"},
	})
	if err != nil {
		log.Fatal(err)
	}

	http.HandleFunc("/checkout", func(w http.ResponseWriter, r *http.Request) {
		user := ffcontext.NewEvaluationContextBuilder(r.Header.Get("X-User-Id")).
			AddCustom("plan", r.Header.Get("X-Plan")).
			Build()
		enabled, err := ffclient.BoolVariation("new-checkout", user, false)
		if err != nil {
			log.Printf("flag evaluation: %v", err)
		}
		if enabled {
			fmt.Fprint(w, "New checkout")
		} else {
			fmt.Fprint(w, "Old checkout")
		}
	})

	srv := &http.Server{Addr: ":8080"}
	go func() {
		if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed {
			log.Fatal(err)
		}
	}()

	ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
	defer stop()
	<-ctx.Done()

	shutdownCtx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
	defer cancel()
	_ = srv.Shutdown(shutdownCtx)
	ffclient.Close()
	log.Println("stopped")
}
# flags.yaml
new-checkout:
  variations:
    enabled: true
    disabled: false
  targeting:
    - query: plan eq "pro"
      variation: enabled
  defaultRule:
    variation: disabled

A request with X-Plan: pro returned "New checkout" and one without it "Old checkout", and on SIGTERM the server drained and closed the flag client before exiting. Polling defaults to 60 seconds; the example uses 10. In production, the retriever can read the file from S3, GitHub, GitLab, Kubernetes, MongoDB, PostgreSQL or Redis instead, and changes apply on the next poll. For several languages, the GO Feature Flag README recommends its relay proxy with OpenFeature providers; the Go module is an option for Go-only projects.

How do I use OpenFeature in Go?

With OpenFeature, the same code works with any provider. This ran with go-sdk v1.20.0 and the flagd provider v0.8.0 in file mode, which reads a local file and re-checks it every 5 seconds by default, printing pro true and free false:

package main

import (
	"context"
	"fmt"
	"log"

	flagd "github.com/open-feature/go-sdk-contrib/providers/flagd/pkg"
	"github.com/open-feature/go-sdk/openfeature"
)

func main() {
	provider, err := flagd.NewProvider(
		flagd.WithFileResolver(),
		flagd.WithOfflineFilePath("flags.json"),
	)
	if err != nil {
		log.Fatal(err)
	}
	if err := openfeature.SetProviderAndWait(provider); err != nil {
		log.Fatal(err)
	}
	defer openfeature.Shutdown()

	client := openfeature.NewClient("checkout")
	for _, plan := range []string{"pro", "free"} {
		evalCtx := openfeature.NewEvaluationContext("user-42", map[string]any{"plan": plan})
		enabled, _ := client.BooleanValue(context.Background(), "new-checkout", false, evalCtx)
		fmt.Println(plan, enabled)
	}
}

Here flags.json holds a flagd flag whose rule turns new-checkout on when plan equals pro. In an HTTP server, you can attach the user to the request's context.Context with openfeature.WithTransactionContext in a middleware, so handlers deeper down evaluate with it (OpenFeature Go).

What should I watch in Go services?

  • Minimum Go versions. OpenFeature's Go SDK, the flagd provider and Flipt's client need Go 1.26, GO Feature Flag 1.26.10, and LaunchDarkly, Flagsmith and DevCycle Go 1.25. An older toolchain either downloads a newer one and raises your module's go line (GOTOOLCHAIN=auto, the default) or fails (GOTOOLCHAIN=local, common in CI images).
  • Native code. Flipt's client runs its WASM engine with Wazero, so it needs no cgo; Statsig's Go Core SDK loads native libraries per platform, with no Windows build listed.
  • One client per process. Initialize once at startup and share it; SDKs hold connections, caches and goroutines.
  • Shut down. Call ffclient.Close(), openfeature.Shutdown() or the vendor's close method on shutdown to stop background goroutines and send pending events. A defer doesn't run after log.Fatal or an unhandled signal, so handle SIGTERM as in the example above.
  • Remote evaluation on hot paths. Flagsmith and PostHog call their API by default; turn on local evaluation for flags checked on every request, and note PostHog's Go SDK polls every 5 minutes by default, slower than its other SDKs.
  • Moved modules. Unleash's Go SDK is now unleash-go-sdk/v6 (the old unleash-client-go repository redirects there, and its v4 line stopped at v4.5.0 in June 2025), and Statsig recommends its Go Core SDK over the legacy go-sdk.

For other languages, see feature flags in Node.js, Python and Java and Spring Boot. For flags kept in Git, see self-hosted vs SaaS. All tools are in the directory.