Quickstart by stack

Go Quickstart

Install the Go SDK from the module registry, evaluate a flag with context, and wire flag evaluation into net/http, Gin, or Echo with the middleware package.

Prerequisites

  • Go 1.25 or later.
  • A server key (prefixed srv_) stored in environment configuration and not committed to source.
  • A flag key you can test in a non-production environment.
Install bash

go get github.com/zenmanage/zenmanage-go
Initialize and evaluate go

package main

import (
    "context"
    "fmt"
    "log"
    "os"

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

func main() {
    cfg, err := zenmanage.NewConfigBuilder().
        WithEnvironmentToken(os.Getenv("ZENMANAGE_SERVER_KEY")).
        Build()
    if err != nil {
        log.Fatal(err)
    }

    client := zenmanage.New(cfg)

    enabled, err := client.IsEnabled(context.Background(), "new-dashboard", "user-123")
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println("enabled:", enabled)
}
net/http middleware go

import (
    "net/http"

    "github.com/zenmanage/zenmanage-go/middleware"
)

mux := http.NewServeMux()
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
    enabled, err := middleware.IsEnabled(r.Context(), "new-feature")
    // ...
})
http.ListenAndServe(":8080", middleware.InjectFlags(client, mux))
Error-handling pattern go

import "errors"

flag, err := client.Flags().Single(ctx, "unknown-flag")
if err != nil {
    var evalErr *zenmanage.EvaluationError
    var fetchErr *zenmanage.FetchRulesError
    switch {
    case errors.As(err, &evalErr):
        log.Println("flag not found:", evalErr.Message)
    case errors.As(err, &fetchErr):
        log.Println("failed to fetch rules:", fetchErr.Message, fetchErr.StatusCode)
    }
}

// Or pass an inline default to avoid the "not found" error entirely.
flag, err = client.Flags().Single(ctx, "unknown-flag", false)

Server-side only

The Go SDK requires a server token (prefixed srv_). Client and mobile keys are rejected at configuration time — use zenmanage-javascript or another browser or mobile SDK for those runtimes.

Framework middleware

Beyond the standard library, the middleware package ships submodules for Gin (middleware/gin) and Echo (middleware/echo), each exposing the same InjectFlags and IsEnabled pattern.

Next step

Take the next integration step in your own stack.

Start with the quickstart that matches your runtime, then return to the reference pages when you need exact request and payload details.

Language and framework names and logos shown above are trademarks or registered trademarks of their respective owners. Their use here is for identification purposes only and does not imply endorsement of, or affiliation with, Zenmanage.