match

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package match implements the simple glob matching used by routing rules to compare namespaces and metadata values.

A pattern is one of four forms: a literal (exact match), a prefix glob ("foo*", starts-with), a suffix glob ("*foo", ends-with), or a contains glob ("*foo*"). A pattern consisting only of '*' (for example "*", "**") matches anything. A "*" anywhere other than the leading or trailing position is rejected at compile time.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Matcher

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

Matcher is a compiled glob pattern. The zero value matches only the empty string. Construct one with Compile.

func Compile

func Compile(pattern string) (Matcher, error)

Compile parses pattern into a Matcher. See the package docs for the supported forms.

func MustCompile

func MustCompile(pattern string) Matcher

MustCompile is like Compile but panics if pattern is invalid. It is meant for package-level variables and tests where an invalid pattern is a programming error.

func (Matcher) Match

func (m Matcher) Match(s string) bool

Match reports whether s satisfies the compiled pattern.

Jump to

Keyboard shortcuts

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