grok

package
v1.18.0 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2024 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrEmptyName arises when pattern name is an empty string
	ErrEmptyName = errors.New("an empty name")
	// ErrEmptyExpression arises when expression is an empty string
	ErrEmptyExpression = errors.New("an empty expression")
	// ErrAlreadyExist arises when pattern with given name alrady exists
	ErrAlreadyExist = errors.New("the pattern already exist")
	// ErrNotExist arises when pattern with given name doesn't exists
	ErrNotExist = errors.New("pattern doesn't exist")
)

Functions

This section is empty.

Types

type Host

type Host map[string]string

Host is a patterns collection. Host does not need to be kept around after all need patterns are generated

func New

func New() Host

New returns new empty host

func NewBase

func NewBase() Host

NewBase creates new Host that filled up with base patterns. To see all base patterns open 'base.go' file.

func (Host) Add

func (h Host) Add(name, expr string) error

Add a new pattern to the Host. If a pattern name already exists the ErrAlreadyExists will be returned.

func (Host) AddFromReader

func (h Host) AddFromReader(r io.Reader) error

AddFromReader appends all patterns from the reader to this Host.

func (Host) Compile

func (h Host) Compile(expr string) (*Pattern, error)

Compile and get pattern without name (and without adding it to this Host)

func (Host) Get

func (h Host) Get(name string) (*Pattern, error)

Get pattern by name from the Host.

func (Host) Must

func (h Host) Must(name, expr string)

Must is like Add but panics if the expression can't be parsed or the name is empty.

type Pattern

type Pattern struct {
	*regexp.Regexp
	// contains filtered or unexported fields
}

func (*Pattern) Names

func (p *Pattern) Names() (ss []string)

Names returns all names that this pattern has in order.

func (*Pattern) Parse

func (p *Pattern) Parse(input string) map[string]string

Parse returns a map of matches on the input. The map can be empty.

func (*Pattern) ParseKeyValues added in v1.13.0

func (p *Pattern) ParseKeyValues(input string) ([]string, []string)

Jump to

Keyboard shortcuts

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