Versions in this module Expand all Collapse all v0 v0.1.0 Dec 5, 2026 Changes in this version + var ErrTypeMismatch = errors.New("flags: type mismatch") + var ErrUnknownFlag = errors.New("flags: unknown flag") + func DefineLike(m *Manager, name string, sample any) error + func FlagName(ctx context.Context) string + func MemoizeMiddleware(next http.Handler) http.Handler + func Require(m *Manager, name string, scope ScopeFunc, opts ...RequireOption) func(http.Handler) http.Handler + func RequireAny(m *Manager, scope ScopeFunc, names ...string) func(http.Handler) http.Handler + func RequireAnyWith(m *Manager, scope ScopeFunc, names []string, opts ...RequireOption) func(http.Handler) http.Handler + func ScopedValue[V any](ctx context.Context, s Scoped, name string) (V, error) + func SortEntries(es []Entry) + func TemplateFuncs(ctx context.Context, m *Manager, scope Scope) map[string]any + func Value[V any](ctx context.Context, m *Manager, name string, scope Scope) (V, error) + func WithRequestCache(ctx context.Context) context.Context + type BoolFlag = Flag[bool] + func DefineBool(m *Manager, name string, r Resolver[bool]) BoolFlag + type Entry struct + Flag string + Scope string + Value []byte + type Flag struct + func Define[V any](m *Manager, name string, r Resolver[V]) Flag[V] + func (f Flag[V]) Active(ctx context.Context, scope Scope) (bool, error) + func (f Flag[V]) Forget(ctx context.Context, scope Scope) error + func (f Flag[V]) Name() string + func (f Flag[V]) Set(ctx context.Context, scope Scope, v V) error + func (f Flag[V]) Value(ctx context.Context, scope Scope) (V, error) + type Manager struct + func NewManager(store Store, opts ...Option) *Manager + func (m *Manager) Activate(ctx context.Context, name string, scope Scope) error + func (m *Manager) Active(ctx context.Context, name string, scope Scope) (bool, error) + func (m *Manager) AllActive(ctx context.Context, scope Scope) ([]string, error) + func (m *Manager) Deactivate(ctx context.Context, name string, scope Scope) error + func (m *Manager) Define(name string, r Resolver[bool]) BoolFlag + func (m *Manager) FlushCache(ctx context.Context) + func (m *Manager) For(scope Scope) Scoped + func (m *Manager) Forget(ctx context.Context, name string, scope Scope) error + func (m *Manager) Names() []string + func (m *Manager) Purge(ctx context.Context, names ...string) error + func (m *Manager) Set(ctx context.Context, name string, scope Scope, value any) error + func (m *Manager) SetForEveryone(ctx context.Context, name string, value any) error + func (m *Manager) Store() Store + type MemStore struct + func NewMemStore() *MemStore + func (s *MemStore) Delete(_ context.Context, flag, scope string) error + func (s *MemStore) Get(_ context.Context, flag, scope string) ([]byte, bool, error) + func (s *MemStore) List(_ context.Context, flag string) ([]Entry, error) + func (s *MemStore) Purge(_ context.Context, flags ...string) error + func (s *MemStore) Set(_ context.Context, flag, scope string, value []byte) error + type Option func(*Manager) + func WithAllowUnknown() Option + type RequireOption func(*requireConfig) + func WithErrorHandler(fn func(w http.ResponseWriter, r *http.Request, err error)) RequireOption + func WithFallback(h http.Handler) RequireOption + type Resolver func(ctx context.Context, scope Scope) (V, error) + func Const[V any](v V) Resolver[V] + func Rollout(pct float64) Resolver[bool] + func RolloutVariants[V any](variants ...Variant[V]) Resolver[V] + type Scope interface + ScopeKey func() string + var Everyone Scope = keyScope(everyoneKey) + var Global Scope = keyScope(globalKey) + func StringScope(kind, id string) Scope + func TeamScope(id string) Scope + func UserIDScope(id int64) Scope + func UserScope(id string) Scope + type ScopeFunc func(r *http.Request) Scope + type Scoped struct + func (s Scoped) Activate(ctx context.Context, name string) error + func (s Scoped) Active(ctx context.Context, name string) (bool, error) + func (s Scoped) AllActive(ctx context.Context) ([]string, error) + func (s Scoped) Deactivate(ctx context.Context, name string) error + func (s Scoped) Forget(ctx context.Context, name string) error + func (s Scoped) Set(ctx context.Context, name string, value any) error + type Store interface + Delete func(ctx context.Context, flag, scope string) error + Get func(ctx context.Context, flag, scope string) (value []byte, ok bool, err error) + List func(ctx context.Context, flag string) ([]Entry, error) + Purge func(ctx context.Context, flags ...string) error + Set func(ctx context.Context, flag, scope string, value []byte) error + type Variant struct + Value V + Weight float64