grep

package
v1.5.7 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(pattern string) func(string) bool

func QuoteMeta

func QuoteMeta(s string) string

QuoteMeta returns a string that quotes all glob pattern meta characters inside the argument text; For example, QuoteMeta(`{foo*}`) returns `\[foo\*\]`.

Types

type Cache

type Cache struct {

	// MaxEntries is the maximum number of cache entries before
	// an item is evicted. Zero means no limit.
	MaxEntries int

	// OnEvicted optionally specifies a callback function to be
	// executed when an entry is purged from the cache.
	OnEvicted func(key Key, value Grep)
	// contains filtered or unexported fields
}

Cache is an LRU cache. It is not safe for concurrent access.

func (*Cache) Add

func (c *Cache) Add(key Key, value Grep)

Add adds a value to the cache.

func (*Cache) Clear

func (c *Cache) Clear()

Clear purges all stored items from the cache.

func (*Cache) Get

func (c *Cache) Get(key Key) (value Grep, ok bool)

Get looks up a key's value from the cache.

func (*Cache) Len

func (c *Cache) Len() int

Len returns the number of items in the cache.

func (*Cache) Remove

func (c *Cache) Remove(key Key)

Remove removes the provided key from the cache.

func (*Cache) RemoveOldest

func (c *Cache) RemoveOldest()

RemoveOldest removes the oldest item from the cache.

type Grep

type Grep interface {
	Match(string) bool
}

Grep represents compiled glob pattern.

func Compile

func Compile(pattern string, separators []byte) (Grep, error)

type Key

type Key string

A Key may be any value that is comparable. See http://golang.org/ref/spec#Comparison_operators

Directories

Path Synopsis
ast
util

Jump to

Keyboard shortcuts

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