gork

package
v1.16.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2021 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const BuiltinPatterns = `` /* 4367-byte string literal not displayed */

Patterns based on https://github.com/logrusorgru/grokky nolint: lll

Variables

This section is empty.

Functions

func ReadPatterns

func ReadPatterns(r io.Reader) (map[string]string, error)

ReadPatterns reads named patterns from an io.Reader

Types

type Env

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

Env is a collection of named patterns

func New

func New() *Env

New returns an environment containing basic patterns

func (*Env) Clone

func (e *Env) Clone() *Env

Clone clones an environment

func (*Env) Compile

func (e *Env) Compile(pattern string) (*Pattern, error)

Compile compiles a pattern expanding named patterns.

func (*Env) MustSet

func (e *Env) MustSet(name string, pattern string)

MustSet compiles and stores a named pattern or panics if the pattern is invalid or exists already.

func (*Env) ReadPatterns

func (e *Env) ReadPatterns(r io.Reader) error

ReadPatterns reads, compiles and adds named patterns to an environment from an io.Reader

func (*Env) Set

func (e *Env) Set(name string, pattern string) error

MustSet compiles and stores a named pattern or fails if the pattern is invalid or exists already.

func (*Env) SetMap

func (e *Env) SetMap(patterns map[string]string) error

SetMap adds multiple patterns to an environment.

type Pattern

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

Pattern can match strings to extract key/value pairs

func (*Pattern) MatchString

func (p *Pattern) MatchString(dst []string, src string) ([]string, error)

MatchString matches src appending key/value pairs to dst. If the text does not match an error is return

func (*Pattern) Regexp

func (p *Pattern) Regexp() string

Regexp returns the full regular expression for this pattern

func (*Pattern) String

func (p *Pattern) String() string

String returns the pattern

Jump to

Keyboard shortcuts

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