GO Feature Flag

Load a flag from GO Feature Flag, the Go-native open-source flag engine.

Schemegoff://
Modulegithub.com/xavidop/mamori/providers/goff
Sensitiveno
Watchpoll
Authflag config retriever (file / URL / bucket)

Install

go get github.com/xavidop/mamori/providers/goff
import _ "github.com/xavidop/mamori/providers/goff"

Using the ref

A goff:// ref points at one flag key. It resolves to that flag’s evaluated variation for a fixed evaluation context (your service).

goff://<flag-key>[#json-key]
PartRequiredWhat it means
<flag-key>yesThe GO Feature Flag flag key.
#json-keynoSelect one field from a JSON variation (via SelectKey).

The variation maps to bytes by type (boolean, string, number, or JSON). A flag that does not exist resolves to not-found.

Examples

  • goff://new-feature resolves to true / false.
  • goff://rollout-config#percentage resolves to the percentage field of a JSON variation.

The evaluation context defaults to a stable targeting key (mamori); override it with WithTargetingKey.

Error classification

Beyond the not-found case, other evaluation failures are classified by go-feature-flag’s OpenFeature-style ErrorCode so mamori.ErrorKind can distinguish them:

ErrorCodemamori kind
PROVIDER_NOT_READYunavailable
PARSE_ERROR, TYPE_MISMATCH, INVALID_CONTEXT, TARGETING_KEY_MISSINGinvalid
anything else (including GENERAL)unknown

GENERAL is go-feature-flag’s catch-all for a failure that fits no other code, so mapping it would be a guess; it stays unknown along with any unrecognized code. The underlying error stays reachable with errors.Is/errors.As when RawVariation returned one.

Watch

GO Feature Flag reloads its flag definitions from the configured retriever on an interval; mamori polls (WithPollInterval + jitter).

Configuration

GO Feature Flag reads its flag definitions from a retriever - a local file, an HTTP URL, or an object-storage bucket:

import goffprov "github.com/xavidop/mamori/providers/goff"

mamori.WithProvider(goffprov.New(goffprov.WithConfigFile("/etc/goff/flags.yaml")))
// or from a URL:
mamori.WithProvider(goffprov.New(goffprov.WithConfigURL("https://cdn.example.com/flags.yaml")))

Verified with an injected fake (un-seeded flags resolve to not-found); live behavior is covered by //go:build integration tests.