submatch

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2022 License: GPL-3.0 Imports: 7 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoSuchKey                 = errors.New("no such key")
	ErrIndexOutOfRange           = errors.New("index out of range")
	ErrUnparsableDestinationType = errors.New("unknown destination type")
	ErrNotValidPtr               = errors.New("not valid pointer")
	TimeType                     = reflect.ValueOf(time.Time{}).Type()
)

Functions

This section is empty.

Types

type FieldNotSetError

type FieldNotSetError struct {
	Field string
}

func (FieldNotSetError) Error

func (fnse FieldNotSetError) Error() string

type Helper

type Helper struct {
	IndexMap map[string]int
	// contains filtered or unexported fields
}

Helper structure definition

func NewHelper

func NewHelper(r *regexp.Regexp) (sm Helper)

NewHelper : creates a new submatch helper from a regexp struct

func (*Helper) GetBytes

func (sh *Helper) GetBytes(key string) ([]byte, error)

GetBytes : Get the matching []byte (if any) extracted from the data matched by the Helper's regexp. Helper needs to be prepared using the Prepare function to work properly.

func (*Helper) Prepare

func (sh *Helper) Prepare(b []byte)

Prepare : this method must be called on any []byte/string you want the helper to work on. It basically apply regex.Regexp.FindSubmatch on b and initializes internal helper member for further processing.

func (*Helper) SetTimeLayout

func (sh *Helper) SetTimeLayout(layout string)

SetTimeLayout : setter for timeLayout field of SubmatchHelper to properly parse timestamps

func (*Helper) Unmarshal

func (sh *Helper) Unmarshal(v interface{}) error

Unmarshal : unmarshal the data found by the Helper's regexp into v. Helper needs to be prepared first through the Prepare function.

Jump to

Keyboard shortcuts

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