Documentation
¶
Overview ¶
Package operatingsystem implements the OperatingSystem parser.
Index ¶
- Variables
- func GetAvailableOperatingSystemFamilies() map[string][]string
- func GetAvailableOperatingSystems() map[string]string
- func GetNameFromId(os string, ver string) string
- func GetOsFamily(osLabel string) string
- func IsDesktopOs(osName string) bool
- type Entry
- type Match
- type Option
- type Parser
- type ParserFactory
- type Version
Constants ¶
This section is empty.
Variables ¶
var AndroidApps = []string{
"com.hisense.odinbrowser",
"com.seraphic.openinet.pre",
"com.appssppa.idesktoppcbrowser",
"every.browser.inc",
}
AndroidApps contains app IDs that indicate Android OS.
var ClientHintMapping = map[string][]string{
"GNU/Linux": {"Linux"},
"Mac": {"MacOS"},
}
ClientHintMapping maps OS names to known client hint values. Mirrors PHP OperatingSystem::$clientHintMapping
var DesktopOsFamilies = []string{
"AmigaOS", "IBM", "GNU/Linux", "Mac", "Unix", "Windows", "BeOS", "Chrome OS",
"OpenVMS",
}
DesktopOsFamilies contains OS families that are known as desktop only. Mirrors PHP OperatingSystem::$desktopOsArray
var FireOsVersionMapping = map[string]string{
"14": "14",
"13": "14",
"12": "14",
"11": "8",
"10": "8",
"9": "7",
"7": "6",
"5": "5",
"4.4.3": "4.5.1",
"4.4.2": "4",
"4.2.2": "3",
"4.0.3": "3",
"4.0.2": "3",
"4": "2",
"2": "1",
}
FireOsVersionMapping maps Android versions to Fire OS versions. Mirrors PHP OperatingSystem::$fireOsVersionMapping
var LineageOsVersionMapping = map[string]string{
"16": "23",
"15": "22",
"14": "21",
"13": "20.0",
"12.1": "19.1",
"12": "19.0",
"11": "18.0",
"10": "17.0",
"9": "16.0",
"8.1.0": "15.1",
"8.0.0": "15.0",
"7.1.2": "14.1",
"7.1.1": "14.1",
"7.0": "14.0",
"6.0.1": "13.0",
"6.0": "13.0",
"5.1.1": "12.1",
"5.0.2": "12.0",
"5.0": "12.0",
"4.4.4": "11.0",
"4.3": "10.2",
"4.2.2": "10.1",
"4.0.4": "9.1.0",
}
LineageOsVersionMapping maps Android versions to Lineage OS versions. Mirrors PHP OperatingSystem::$lineageOsVersionMapping
var OSFamilies = map[string][]string{
"Android": {
"AND", "CYN", "FIR", "REM", "RZD", "MLD", "MCD", "YNS", "GRI", "HAR",
"ADR", "CLR", "BOS", "REV", "LEN", "SIR", "RRS", "WER", "PIC", "ARM",
"HEL", "BYI", "RIS", "PUF", "LEA", "MET", "OHS", "SMA",
},
"AmigaOS": {"AMG", "MOR", "ARO"},
"BlackBerry": {"BLB", "QNX"},
"Brew": {"BMP"},
"BeOS": {"BEO", "HAI"},
"Chrome OS": {"COS", "CRS", "FYD", "SEE"},
"Firefox OS": {"FOS", "KOS"},
"Gaming Console": {"WII", "PS3"},
"Google TV": {"GTV"},
"IBM": {"OS2"},
"iOS": {"IOS", "ATV", "WAS", "IPA"},
"RISC OS": {"ROS"},
"GNU/Linux": {
"LIN", "ARL", "DEB", "KNO", "MIN", "UBT", "KBT", "XBT", "LBT", "FED",
"RHT", "VLN", "MDR", "GNT", "SAB", "SLW", "SSE", "CES", "BTR", "SAF",
"OSS",
"ORD", "TOS", "RSO", "DEE", "FRE", "MAG", "FEN", "CAI", "PCL", "HAS",
"LOS", "DVK", "ROK", "OWR", "OTV", "KTV", "PUR", "PLA", "FUC", "PAR",
"FOR", "MON", "KAN", "ZEN", "LND", "LNS", "CHN", "AMZ", "TEN", "CST",
"NOV", "ROU", "ZOR", "RED", "KAL", "ORA", "VID", "TIV", "BSN", "RAS",
"UOS", "PIO", "FRI", "LIR", "WEB", "SER", "ASP", "AOS", "LOO", "EUL",
"SCI", "ALP", "CLO", "ROC", "OVZ", "PVE", "RST", "EZX", "GNS", "JOL",
"TUR", "QTP", "WPO", "PAN", "VIZ", "AZU", "COL",
},
"Mac": {"MAC"},
"Mobile Gaming Console": {"PSP", "NDS", "XBX"},
"OpenVMS": {"OVS"},
"Real-time OS": {"MTK", "TDX", "MRE", "JME", "REX", "RXT", "KOL"},
"Other Mobile": {"WOS", "POS", "SBA", "TIZ", "SMG", "MAE", "LUN", "GEO"},
"Symbian": {"SYM", "SYS", "SY3", "S60", "S40"},
"Unix": {
"SOS", "AIX", "HPX", "BSD", "NBS", "OBS", "DFB", "SYL", "IRI", "T64",
"INF", "ELE", "GNX", "ULT", "NWS", "NXT", "SBL",
},
"WebTV": {"WTV"},
"Windows": {"WIN"},
"Windows Mobile": {"WPH", "WMO", "WCE", "WRT", "WIO", "KIN"},
"Other Smart TV": {"WHS", "TIT", "ORS"},
}
OSFamilies maps OS family names to short codes of member OSes. Mirrors PHP OperatingSystem::$osFamilies
var OperatingSystems = map[string]string{}/* 192 elements not displayed */
OperatingSystems maps short codes to full OS names. Mirrors PHP OperatingSystem::$operatingSystems
Functions ¶
func GetAvailableOperatingSystemFamilies ¶
GetAvailableOperatingSystemFamilies returns all available OS families.
func GetAvailableOperatingSystems ¶
GetAvailableOperatingSystems returns all available operating systems.
func GetNameFromId ¶
GetNameFromId returns the full name for the given short name.
func GetOsFamily ¶
GetOsFamily returns the OS family for the given OS (by short name or name).
func IsDesktopOs ¶
IsDesktopOs returns true if the OS is desktop only.
Types ¶
type Entry ¶
type Entry struct {
Regex string `yaml:"regex"`
Name string `yaml:"name"`
Version string `yaml:"version"`
Versions []Version `yaml:"versions,omitempty"`
// contains filtered or unexported fields
}
Entry represents a single OS definition from the YAML regex file.
type Match ¶
type Match struct {
Name string `json:"name" yaml:"name"`
ShortName string `json:"short_name" yaml:"short_name"`
Version string `json:"version" yaml:"version"`
Platform string `json:"platform" yaml:"platform"`
Family string `json:"family" yaml:"family"`
}
Match represents the result of a successful OS detection. This matches the PHP return structure.
type Option ¶
type Option func(*Parser)
Option is a functional option for configuring Parser behavior.
func WithClientHints ¶
func WithClientHints(ch *clienthints.ClientHints) Option
WithClientHints sets client hints for the parser.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser parses a single user agent for OS information. Created via ParserFactory.NewParser() - do not instantiate directly.
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(opts ...common.FactoryOption) (*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.