simplereach / 51degrees

51Degrees device detection for Go
BSD 2-Clause "Simplified" License
3 stars 3 forks source link

51Degrees for golang

51Degrees UserAgent. Note that the primary difference between https://github.com/hdczsf/51degrees.go and https://github.com/simplereach/51degrees is that the SimpleReach version supports the 3.2 data file format.

Installation

go get github.com/simplereach/51degrees

Example

package main

import (
    "fmt"
    "github.com/simplereach/51degrees"
)

func main() {
    properties := "DeviceType, IsMobile, IsSmartPhone, IsTablet, IsTv, HardwareName, HardwareVendor, HardwareModel, BrowserName, BrowserVersion, PlatformName, PlatformVersion, ScreenPixelsWidth, ScreenPixelsHeight"
    testUA := "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.124 Safari/537.36"
    item, err := NewFiftyoneDegrees("51Degrees-EnterpriseV3_2.dat", properties)
    if err != nil {
        fmt.Println("err=", err)
        return
    }
    fmt.Println(item.Parse(testUA))
    item.Close()
}