library

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: LGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package library implements the Library client parser.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Regex   string `yaml:"regex"`
	Name    string `yaml:"name"`
	Version string `yaml:"version"`
	// contains filtered or unexported fields
}

Entry represents a single library definition from the YAML regex file.

func (*Entry) GetRegex

func (e *Entry) GetRegex() string

GetRegex is used for keyword extraction / indexing.

func (*Entry) Order

func (e *Entry) Order() int

Order preserves YAML order for deterministic "first match wins" selection.

type Match

type Match struct {
	Type    string `json:"type"`
	Name    string `json:"name"`
	Version string `json:"version"`
}

Match represents the result of a successful library detection. This matches the PHP return structure (type/name/version).

type Option

type Option func(*Parser)

Option is a functional option for configuring Parser behavior.

type Parser

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

Parser parses a single user agent for library information. Created via ParserFactory.NewParser() - do not instantiate directly.

func (*Parser) Parse

func (p *Parser) Parse() *Match

Parse detects libraries and returns a Match, or nil if not detected. Mirrors PHP: DeviceDetector\Parser\Client\Library::parse(): ?array

type ParserFactory

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

ParserFactory holds pre-compiled regexes and creates Parser instances. Thread-safe for concurrent use - create once, use from multiple goroutines.

func NewDefaultParserFactory

func NewDefaultParserFactory() (*ParserFactory, error)

NewDefaultParserFactory is an alias for NewParserFactory kept for compatibility.

func NewParserFactory

func NewParserFactory(opts ...common.FactoryOption) (*ParserFactory, error)

NewParserFactory creates a factory by loading and compiling regexes from the embedded YAML DB.

func (*ParserFactory) NewParser

func (f *ParserFactory) NewParser(ua string, opts ...Option) *Parser

NewParser creates a new Parser instance for parsing a single user agent.

func (*ParserFactory) Parse

func (f *ParserFactory) Parse(ua string, opts ...Option) *Match

Parse is a convenience method that creates a parser and immediately parses.

Jump to

Keyboard shortcuts

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