GO Feature Flag
Load a flag from GO Feature Flag, the Go-native open-source flag engine.
| Scheme | goff:// |
| Module | github.com/xavidop/mamori/providers/goff |
| Sensitive | no |
| Watch | poll |
| Auth | flag 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]
| Part | Required | What it means |
|---|---|---|
<flag-key> | yes | The GO Feature Flag flag key. |
#json-key | no | Select 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-featureresolves totrue/false.goff://rollout-config#percentageresolves to thepercentagefield 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:
| ErrorCode | mamori kind |
|---|---|
PROVIDER_NOT_READY | unavailable |
PARSE_ERROR, TYPE_MISMATCH, INVALID_CONTEXT, TARGETING_KEY_MISSING | invalid |
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.