pathquery

package
v0.212.0 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2026 License: MIT Imports: 1 Imported by: 0

README

pathquery

pathquery is the format-neutral wildcard kernel shared by dynamic path evaluators. * matches zero or more Unicode code points and ? matches one. Matching is immutable, concurrency-safe, UTF-8 aware, and allocation-free.

Relation, ParseRelation, Relate, and RelateString provide the format-neutral predicate algebra shared by query languages. Formats still own operand parsing and coercion; the stdlib owns equality/order duality, complements, and wildcard relation semantics.

It was extracted from the GoForge GJSON compatibility evaluator so JSON, CBOR, configuration, and future document-query packages do not each grow subtly different wildcard implementations.

Documentation

Overview

Package pathquery supplies format-neutral matching primitives for dynamic path evaluators. It is authored in Go+ and generated into portable Go.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Match

func Match(pattern, value string) bool

Match compares UTF-8 strings without allocating. Invalid UTF-8 bytes are treated consistently as RuneError code points.

func Relate

func Relate[T any](
	left, right T,
	relation Relation,
	equal func(T, T) bool,
	less func(T, T) bool,
) bool

Relate evaluates equality and ordering without imposing a format's scalar representation. Like and NotLike are intentionally handled by RelateString.

func RelateString

func RelateString(left, right string, relation Relation) bool

RelateString adds wildcard Like/NotLike to ordinary lexical relations.

Types

type Pattern

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

Pattern is an immutable wildcard pattern. '*' matches zero or more Unicode code points and '?' matches exactly one code point.

func Compile

func Compile(source string) Pattern

func (Pattern) Match

func (pattern Pattern) Match(value string) bool

func (Pattern) String

func (pattern Pattern) String() string

type Relation

type Relation uint8

Relation is the format-neutral algebra used by path-query predicates. Concrete formats retain responsibility for parsing and coercing operands.

const (
	Equal Relation = iota
	NotEqual
	Less
	LessOrEqual
	Greater
	GreaterOrEqual
	Like
	NotLike
)

func ParseRelation

func ParseRelation(source string) (Relation, bool)

ParseRelation recognizes the conventional dynamic-query spellings.

Jump to

Keyboard shortcuts

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