profile

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package profile implements FastConf's tiny boolean profile-expression language (Phase 13). An expression is a propositional formula over profile names with the operators '&' (AND), '|' (OR), '!' (NOT) and parentheses. An identifier evaluates to true iff it is in the active profile set.

Examples:

"prod"                  → active("prod")
"prod & eu"             → active("prod") && active("eu")
"prod & (eu | us)"      → active("prod") && (active("eu") || active("us"))
"prod & !canary"        → active("prod") && !active("canary")

The parser is recursive-descent and dependency-free; FastConf's main module never grows a third-party expression library.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compile

func Compile(expr string) (func(Set) bool, error)

Compile parses expr once and returns a reusable evaluator. Empty expression compiles to a constant-true predicate. Phase 20 BUG-205: callers can validate user-supplied expressions at startup time.

func Eval

func Eval(expr string, active Set) (bool, error)

Eval parses and evaluates the expression against the active set.

Types

type Set

type Set map[string]struct{}

Set is a small string-set helper used by the evaluator.

func NewSet

func NewSet(active ...string) Set

NewSet builds a Set from the given profile names.

func (Set) Has

func (s Set) Has(name string) bool

Has reports whether name is a member of the active set.

Jump to

Keyboard shortcuts

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