Skip to content

Go quickstart

In a few minutes your Go service will evaluate feature flags in-process — no network hop per check, no latency in your request path, one poll serving every request your process handles.

Zero runtime dependencies: the SDK’s require block is empty, and stays that way.

The SDK is pre-release and its repository isn’t public yet. If your team has been given access, the module path below is where it lives.

Terminal window
go get github.com/FortressFlag/FortressFlag_SDK_go

This SDK uses a server key (ffs_…), and it’s the opposite of the client keys the mobile and web SDKs ship: it can download your full ruleset, targeting rules included. Treat it exactly like a database password — an environment variable or a secret manager, never code, never a repository, never a log. The two key classes, side by side.

package main
import (
"context"
"os"
"time"
fortressflag "github.com/FortressFlag/FortressFlag_SDK_go"
)
func main() {
client, err := fortressflag.New(fortressflag.Configuration{
Key: os.Getenv("FF_SERVER_KEY"),
})
if err != nil {
// The one place the SDK can error: a malformed configuration,
// before anything serves.
panic(err)
}
defer client.Close()
startCtx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
client.Start(startCtx) // blocks until the first ruleset arrives (or the context ends)
cancel()
// ... your service runs; flag checks are now in-memory function calls.
}

Start never returns a fatal — if the first fetch can’t land in time, the client keeps trying in the background and your callers get their defaults meanwhile.

enabled := client.Bool("new-checkout", fortressflag.Context{
Key: "user-42", // your stable context key: a user id, a session id — your choice
Tags: map[string]string{"cohort": "beta"},
}, false) // the fallback if the flag is unknown or nothing was ever fetched

client.String and client.Number work the same way. The context Key is what percentage rollouts bucket on — pass the same identifier consistently and each user gets a stable cohort. It’s your data: the SDK never validates, stores, or logs it.

That’s it — your service is evaluating flags locally. A dashboard change reaches every process within about a minute.

Bool, String, and Number always answer and never panic — a flagging problem must never take down your service. A restarted process serves your call-site fallbacks until its first fetch lands (or set CachePath in the configuration to persist the last ruleset to a file of your choosing, and restarts resume from it instantly). Even a revoked key doesn’t break anything: the SDK keeps evaluating with the last ruleset it downloaded until you hand it a new key.