https://github.com/benbjohnson/agency
A fast user agent string parser for Go.
https://github.com/benbjohnson/agency
Last synced: 10 months ago
JSON representation
A fast user agent string parser for Go.
- Host: GitHub
- URL: https://github.com/benbjohnson/agency
- Owner: benbjohnson
- License: mit
- Created: 2013-12-05T19:08:32.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2017-06-01T16:05:17.000Z (over 8 years ago)
- Last Synced: 2025-03-15T23:56:14.142Z (10 months ago)
- Language: Go
- Homepage:
- Size: 437 KB
- Stars: 60
- Watchers: 3
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Agency
Agency is a fast user-agent parser in pure Go. It uses a simple tokenizer and weighted tokens to determine the correct device type, category and browser.
## Usage
To use Agency, simply import the package and call `Scan()`:
```go
import "github.com/benbjohnson/agency"
ua := agency.Scan("Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 blah blah...")
```
## User Agent Info
The `Scan()` function returns a `UserAgent` with the following string properties:
```
Type
----------
Desktop
Tablet
Mobile
Category
----------
Windows
Mac
Linux
iOS
Blackberry
Android
Browser
----------
Chrome
Safari
Internet Explorer
```