vendorfragment

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: LGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package vendorfragment implements the VendorFragment parser.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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 vendor fragment information. Created via ParserFactory.NewParser() - do not instantiate directly.

func (*Parser) MatchedRegex

func (p *Parser) MatchedRegex() string

MatchedRegex returns the fragment (regex) that matched during the last Parse(). Mirrors PHP: VendorFragment::getMatchedRegex(): ?string

func (*Parser) Parse

func (p *Parser) Parse() map[string]string

Parse matches the UA against vendor fragments and returns the detected brand. Mirrors PHP: VendorFragment::parse(): ?array returning ['brand' => $brand]

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 NewParserFactory

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

NewParserFactory creates a factory by loading and compiling vendor fragment 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.

Jump to

Keyboard shortcuts

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