Socket
Socket
Sign inDemoInstall

github.com/sebest/go-uasparser

Package Overview
Dependencies
0
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    github.com/sebest/go-uasparser

Package uas provides a go implementation of the http://user-agent-string.info/ processor. Standard usage is to provide a user-agent string to the Parse method of a Manifest instance and retrieve an Agent instance in return. From the Agent, you can obtain: browser details, operating system details, and device details. You must create a Manifest instance by providing an XML file from the UAS.info site (http://user-agent-string.info/rpc/get_data.php?key=free&format=xml&download=y) to the LoadFile function; or you can provide a Reader of similar ilk to the Load function. This package currently doesn't support downloading Manifests automatically, but you can also easily create new instances of different Manifests; i.e. a Manifest is not a global object. This package also does not yet support the .ini format; mostly this was to make processing easier by using the built-in XML unmarshalling capabilities of Go. Given a Manifest, you can now easily parse an Agent like so: You can check out the model structure to figure out what other values are available. Unlike other implementations, the values are not simply returned as a flat map. Currently, robots are treated differently in that any agent recognized as one is returned from Parse as a nil value. You can check to see if the agent is indeed a robot by asking if it's so:


Version published

Readme

Source

go-uasparser

A Go implementation of the user-agent-string.info (UAS.info) User-Agent string analysis tool. See the GoDoc for more detailed usage.

Disclaimer(s)

This package does its best to similarly implement the logic from the PHP implementation found on UAS.info; except where the documentation states that it didn't want to. Should you find glaring mistakes, please do open an issue or a pull request.

License

go-uasparser is released under the MIT license. See MIT LICENSE.

FAQs

Last updated on 23 Sep 2014

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc