Back to

Package globset

Latest Go to latest

The latest major version is .

Published: Aug 13, 2020 | License: Apache-2.0 | Module:


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


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.

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier