flags

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 28, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package flags provides a small, in-memory set of boolean feature flags.

Flags are explicit application state: create a Set during startup, pass it to the components that need it, and update it at runtime with Set. The package does not provide global state or persistence.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Set

type Set struct {
	// contains filtered or unexported fields
}

Set is a concurrency-safe collection of boolean feature flags.

The zero value is ready to use. A nil *Set behaves like an empty set when queried with Enabled.

func FromEnv

func FromEnv() *Set

FromEnv parses the FLAGS environment variable.

func New

func New(names ...string) *Set

New returns a Set with names enabled. Empty names are ignored and surrounding whitespace is trimmed.

func Parse

func Parse(csv string) *Set

Parse returns a Set containing the enabled names in a comma-separated string. Empty items are ignored and surrounding whitespace is trimmed.

func (*Set) Enabled

func (s *Set) Enabled(name string) bool

Enabled reports whether name is enabled. It returns false for an empty name or a nil receiver.

func (*Set) Names

func (s *Set) Names() []string

Names returns the enabled flag names in sorted order.

func (*Set) Set

func (s *Set) Set(name string, on bool)

Set enables or disables name. Empty names are ignored.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL