Help us shape the future of Go! Take the 2026 Go Developer Survey

carbrowser

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Brand  string
	Regex  string  `yaml:"regex"`
	Device string  `yaml:"device"`
	Model  string  `yaml:"model,omitempty"`
	Models []Model `yaml:"models,omitempty"`
	// contains filtered or unexported fields
}

Entry represents a single brand entry from car_browsers.yml.

func (*Entry) GetRegex

func (e *Entry) GetRegex() string

GetRegex implements common.Pattern for keyword 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"`
	Brand string `json:"brand"`
	Model string `json:"model"`
}

Match is the parsed device result for car browser detection. Mirrors the PHP test fixtures expectation: {type, brand, model}.

type Model

type Model struct {
	Regex  string `yaml:"regex"`
	Model  string `yaml:"model"`
	Brand  string `yaml:"brand,omitempty"`
	Device string `yaml:"device,omitempty"`
}

Model represents a model-specific rule inside an entry.

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

func (*Parser) Parse

func (p *Parser) Parse() *Match

Parse detects car browser devices and returns a Match, or nil if not detected. Mirrors PHP: DeviceDetector\Parser\Device\CarBrowser::parse(): ?array

type ParserFactory

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

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

func NewDefaultParserFactory

func NewDefaultParserFactory() (*ParserFactory, error)

NewDefaultParserFactory loads regexes from the canonical repo path.

func NewParserFactory

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

NewParserFactory loads and compiles the car browser regex DB 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