All Projects → erizocosmico → detect

erizocosmico / detect

Licence: MIT license
Golang library to detect the device platform given an user agent.

Programming Languages

go
31211 projects - #10 most used programming language

detect

Build Status License GoDoc

Golang library to detect the device platform given an user agent.

package main

import (
        "fmt"

        "github.com/mvader/detect"
)

func main() {
        var userAgent = "Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/4A102 Safari/419"

        platform := detect.Platform(userAgent)
        if platform == detect.Android {
                fmt.Println("Android platform detected!")
        } else {
                fmt.Printf("Platform %s detected instead :(\n", platform)
        }

        if detect.IsMobile(userAgent) {
                fmt.Println("Is mobile!")
        }
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].