filter

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasMeta

func HasMeta(s string) bool

HasMeta reports whether path contains any magic glob characters.

Types

type CombinedFilter

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

CombinedFilter matches if ANY of its sub-filters match (OR logic).

func (*CombinedFilter) Match

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

type Filter

type Filter interface {
	Match(string) bool
}

func Compile

func Compile(filters []string) (Filter, error)

Compile takes a list of string filters and returns a Filter interface for matching a given string against the filter list (OR logic).

Patterns surrounded by / are treated as regular expressions:

f, _ := Compile([]string{"*error*", "/(?i)panic|segfault/"})
f.Match("an error occurred")    // true (glob match)
f.Match("KERNEL PANIC")         // true (regex match)
f.Match("normal log")           // false

Plain patterns support glob matching:

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

func NewIncludeExcludeFilter

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

func NewIncludeExcludeFilterDefaults

func NewIncludeExcludeFilterDefaults(
	include []string,
	exclude []string,
	includeDefault bool,
	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