filter

package
v1.40.4 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 3 Imported by: 30 modules, 211 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const WildcardCharacters = "*?{}[]!"

Variables

This section is empty.

Functions

This section is empty.

Types

type Filter

type Filter interface {
	Match(string) bool
}

func Compile

func Compile(filters []string, separators ...rune) (Filter, error)

Compile takes a list of string filters and returns a Filter interface for matching a given string against the filter list. The filter list supports glob matching with separators too, ie:

f, err := Compile([]string{"cpu", "mem", "net*"})
f.Match("cpu")     // true
f.Match("network") // true
f.Match("memory")  // false

separators are only to be used for globbing filters, ie:

f, err := Compile([]string{"cpu.*.count"}, '.')
f.Match("cpu.count")     // false
f.Match("cpu.measurement.count") // true
f.Match("cpu.field.measurement.count")  // false

Compile will return nil if the filter list is empty.

func MustCompile added in v1.24.0

func MustCompile(filters []string, separators ...rune) Filter

func NewIncludeExcludeFilter

func NewIncludeExcludeFilter(include, exclude []string) (Filter, error)

func NewIncludeExcludeFilterDefaults added in v1.19.0

func NewIncludeExcludeFilterDefaults(include, exclude []string, includeDefault, excludeDefault bool) (Filter, error)

type IncludeExcludeFilter

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

func (*IncludeExcludeFilter) Match

func (f *IncludeExcludeFilter) Match(s string) bool

Jump to

Keyboard shortcuts

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