User agent parsing
First install the library with:
go get xojoc.pw/useragent
see godoc for the complete documentation. # How it works? Lasciate ogne speranza, voi ch’intrate. -Dante Parsing user agent strings is a hell. There is no standard for user agent strings, so useragent must use some heuristics. The site http://www.useragentstring.com/ has been invaluable during development. Some relevant links are also:
If you think useragent doesn’t parse correctly a particular user agent string, just open an issue :).
Why this library?
useragent doesn’t just split the user agent string and look for specific strings like other parsers, but it has specific parser for the most common browsers/crawlers and falls back to a generic parser for everything else. Its main features are:
- Simple and stable API.
- High precision in detection of the most common browsers/crawlers.
- Detects mobile/tablet devices.
- OS detection.
- URL with more information about the user agent (usually it’s the home page).
- Security level detection when reported by browsers.
useragent is released under the GPLv3 or later, see COPYING.Get the code