Back to

package filterset

Latest Go to latest
Published: Jun 16, 2020 | License: Apache-2.0 | Module:


Package filterset provides an interface for matching strings against a set of string filters.


type Config

type Config struct {
	MatchType    MatchType      `mapstructure:"match_type"`
	RegexpConfig *regexp.Config `mapstructure:"regexp"`

Config configures the matching behavior of a FilterSet.

type FilterSet

type FilterSet interface {
	// Matches returns true if the given string matches at least one
	// of the filters encapsulated by the FilterSet.
	Matches(string) bool

FilterSet is an interface for matching strings against a set of filters.

func CreateFilterSet

func CreateFilterSet(filters []string, cfg *Config) (FilterSet, error)

CreateFilterSet creates a FilterSet from yaml config.

type MatchType

type MatchType string

MatchType describes the type of pattern matching a FilterSet uses to filter strings.

const (
	// Regexp is the FilterType for filtering by regexp string matches.
	Regexp MatchType = "regexp"
	// Strict is the FilterType for filtering by exact string matches.
	Strict MatchType = "strict"
	// MatchTypeFieldName is the mapstructure field name for MatchType field.
	MatchTypeFieldName = "match_type"
Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
f or F : Jump to identifier