globset

package
v0.0.0-...-d3da680 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package globset preprocesses []identity.Glob for faster querying.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

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

Builder builds GlobSet from individual globs.

Keeps the cache of compiled regexps internally.

func NewBuilder

func NewBuilder() *Builder

NewBuilder constructs new Builder instance.

func (*Builder) Add

func (b *Builder) Add(g identity.Glob) error

Add adds a glob to the set being constructed.

Returns an error if the glob is malformed.

func (*Builder) Build

func (b *Builder) Build() (GlobSet, error)

Build returns the fully constructed set or nil if it is empty.

Returns an error if some glob can't be compiled into a regexp.

func (*Builder) Reset

func (b *Builder) Reset()

Reset prepares the builder for building a new GlobSet.

Keeps the cache of compiled regexps.

type GlobSet

type GlobSet map[identity.Kind]*regexp.Regexp

GlobSet encodes same set of identities as some []identity.Glob.

For each possible identity type it has a single regexp against an identity value which tests whether it is in the set or not.

Construct it via Builder.

func (GlobSet) Has

func (gs GlobSet) Has(id identity.Identity) bool

Has checks whether 'id' is in the set.

Malformed identities are considered to be not in the set. 'nil' GlobSet is considered empty.

Jump to

Keyboard shortcuts

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