UserAgent
![GoDoc](https://godoc.org/github.com/mssola/user_agent?status.png)
UserAgent is a Go library that parses HTTP User Agents.
Usage
package main
import (
"fmt"
"github.com/mssola/user_agent"
)
func main() {
ua := user_agent.New("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11")
fmt.Printf("%v\n", ua.Mobile())
fmt.Printf("%v\n", ua.Bot())
fmt.Printf("%v\n", ua.Mozilla())
fmt.Printf("%v\n", ua.Platform())
fmt.Printf("%v\n", ua.OS())
name, version := ua.Engine()
fmt.Printf("%v\n", name)
fmt.Printf("%v\n", version)
name, version = ua.Browser()
fmt.Printf("%v\n", name)
fmt.Printf("%v\n", version)
ua.Parse("Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)")
fmt.Printf("%v\n", ua.Bot())
name, version = ua.Browser()
fmt.Printf("%v\n", name)
fmt.Printf("%v\n", version)
}
Copyright © 2012-2019 Miquel Sabaté Solà, released under the MIT License.