{"id":16800719,"url":"https://github.com/houseme/mobiledetect","last_synced_at":"2025-04-11T00:31:54.101Z","repository":{"id":57658342,"uuid":"468812995","full_name":"houseme/mobiledetect","owner":"houseme","description":"Go Mobile Detect is a lightweight Go package imported from PHP for detecting mobile devices (including tablets).Go/Golang parser for user agent strings","archived":false,"fork":false,"pushed_at":"2022-03-13T13:43:20.000Z","size":350,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-24T21:13:57.584Z","etag":null,"topics":["detect","device-detection","go","go-mobile-detect","golang","mobile","mobile-detect","mobile-redirects","user-agent-parser","user-agent-parsing","user-agents"],"latest_commit_sha":null,"homepage":"https://houseme.github.io/mobiledetect/","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/houseme.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":["https://paypal.me/houseme"]}},"created_at":"2022-03-11T15:58:08.000Z","updated_at":"2024-08-11T16:46:31.000Z","dependencies_parsed_at":"2022-09-16T04:30:18.847Z","dependency_job_id":null,"html_url":"https://github.com/houseme/mobiledetect","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/houseme%2Fmobiledetect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/houseme%2Fmobiledetect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/houseme%2Fmobiledetect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/houseme%2Fmobiledetect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/houseme","download_url":"https://codeload.github.com/houseme/mobiledetect/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248322267,"owners_count":21084334,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["detect","device-detection","go","go-mobile-detect","golang","mobile","mobile-detect","mobile-redirects","user-agent-parser","user-agent-parsing","user-agents"],"created_at":"2024-10-13T09:34:48.694Z","updated_at":"2025-04-11T00:31:54.064Z","avatar_url":"https://github.com/houseme.png","language":"Go","funding_links":["https://paypal.me/houseme"],"categories":[],"sub_categories":[],"readme":"# Go MobileDetect\n\n Library for detecting mobile devices and tablets\n\n Go Mobile Detect is a lightweight Go package imported from PHP for detecting mobile devices (including tablets).\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/houseme/mobiledetect.svg)](https://pkg.go.dev/github.com/houseme/mobiledetect)\n[![Go](https://github.com/houseme/mobiledetect/actions/workflows/go.yml/badge.svg)](https://github.com/housemecn/mobiledetect/actions/workflows/go.yml)\n![GitHub](https://img.shields.io/github/license/houseme/mobiledetect?style=plastic)\n![GitHub go.mod Go version (branch)](https://img.shields.io/github/go-mod/go-version/houseme/mobiledetect/main?style=flat-square)\n![GitHub release (latest by date)](https://img.shields.io/github/v/release/houseme/mobiledetect?style=flat-square)\n![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/houseme/mobiledetect?style=flat-square)\n\n### What is it?\n\nIt uses the User-Agent string combined with specific HTTP headers to detect the mobile environment.\n\nThe package is imported from [MobileDetect](http://mobiledetect.net/) which was originally written in PHP.\n\nGo/Golang parser for user agent strings [README](ua/README.md)\n\n\n### Installation \n\n```shell\ngo get -u -v github.com/houseme/mobiledetect \n```\n\n### Updates \n\nVersion 1.2.1\n\n\n### Why is it useful?\n\nThere are different ways of using the package: \n\n- [Basic usage](examples/app.go) \n- [Parsing user agent](examples/ua/ua.go) \n- [Basic router implementation](examples/router/main.go)\n- [Handler interface implementation](examples/handler/main.go)\n- [Mux interface implementation](examples/mux/main.go)\n\n### Go/Golang package for parsing user agent strings\n\nPackage `ua.New(userAgent string)` function parses browser's and bot's user agents strings and determins:\n+ User agent name and version (Chrome, Firefox, Googlebot, etc.)\n+ Operating system name and version  (Windows, Android, iOS etc.)\n+ Device type (mobile, desktop, tablet, bot)\n+ Device name if available (iPhone, iPad, Huawei VNS-L21)\n+ URL provided by the bot (http://www.google.com/bot.html etc.)\n\n#### Status\n\n    Still need some work on detecting Android device names.\n\n    Fill free to report an issue for any User-Agent string not recognized or misinterpreted.\n\n#### Example for parsing user agent strings\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"strings\"\n\n    \"github.com/houseme/mobiledetect/ua\"\n)\n\nfunc main() {\n    userAgents := []string{\n        \"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/10.1.2 Safari/603.3.8\",\n        \"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36\",\n        \"Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_2 like Mac OS X) AppleWebKit/603.2.4 (KHTML, like Gecko) Version/10.0 Mobile/14F89 Safari/602.1\",\t\n        \"Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_2 like Mac OS X) AppleWebKit/603.2.4 (KHTML, like Gecko) FxiOS/8.1.1b4948 Mobile/14F89 Safari/603.2.4\",\n        \"Mozilla/5.0 (iPad; CPU OS 10_3_2 like Mac OS X) AppleWebKit/603.2.4 (KHTML, like Gecko) Version/10.0 Mobile/14F89 Safari/602.1\",\n        \"Mozilla/5.0 (Linux; Android 4.3; GT-I9300 Build/JSS15J) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.125 Mobile Safari/537.36\",\n        \"Mozilla/5.0 (Android 4.3; Mobile; rv:54.0) Gecko/54.0 Firefox/54.0\",\n        \"Mozilla/5.0 (Linux; Android 4.3; GT-I9300 Build/JSS15J) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.91 Mobile Safari/537.36 OPR/42.9.2246.119956\",\n        \"Opera/9.80 (Android; Opera Mini/28.0.2254/66.318; U; en) Presto/2.12.423 Version/12.16\",\n    }\n\n    for _, s := range userAgents {\n        ua := ua.New(s)\n        fmt.Println()\n        fmt.Println(ua.UA())\n        fmt.Println(strings.Repeat(\"=\", len(ua.UA())))\n        fmt.Println(\"Name:\", ua.Name(), \"v\", ua.Version())\n        fmt.Println(\"OS:\", ua.OS(), \"v\", ua.OSVersion())\n        fmt.Println(\"Device:\", ua.Device())\n        if ua.Mobile() {\n            fmt.Println(\"(Mobile)\")\n        }\n        if ua.Tablet() {\n            fmt.Println(\"(Tablet)\")\n        }\n        if ua.Desktop() {\n            fmt.Println(\"(Desktop)\")\n        }\n        if ua.Bot() {\n            fmt.Println(\"(Bot)\")\n        }\n        if ua.URL() != \"\" {\n            fmt.Println(ua.URL())\n        }\n        fmt.Printf(\"%v\\n\", ua.Mobile())   // =\u003e true\n        fmt.Printf(\"%v\\n\", ua.Bot())      // =\u003e false\n        fmt.Printf(\"%v\\n\", ua.Mozilla())  // =\u003e \"5.0\"\n        fmt.Printf(\"%v\\n\", ua.Model())    // =\u003e \"Nexus One\"\n    \n        fmt.Printf(\"%v\\n\", ua.Platform()) // =\u003e \"Linux\"\n        fmt.Printf(\"%v\\n\", ua.OS())       // =\u003e \"Android 2.3.7\"\n    \n        name, version := ua.Engine()\n        fmt.Printf(\"%v\\n\", name)          // =\u003e \"AppleWebKit\"\n        fmt.Printf(\"%v\\n\", version)       // =\u003e \"533.1\"\n    \n        name, version = ua.Browser()\n        fmt.Printf(\"%v\\n\", name)          // =\u003e \"Android\"\n        fmt.Printf(\"%v\\n\", version)       // =\u003e \"4.0\"\n    \n        // Let's see an example with a bot.\n    \n        ua.Parse(\"Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)\")\n    \n        fmt.Printf(\"%v\\n\", ua.Bot())      // =\u003e true\n    \n        name, version = ua.Browser()\n        fmt.Printf(\"%v\\n\", name)          // =\u003e Googlebot\n        fmt.Printf(\"%v\\n\", version)       // =\u003e 2.1\n    }\n}\n```\n\n### License\n\nGo Mobile Detect is an open-source script released under [MIT License](http://www.opensource.org/licenses/mit-license.php). thanks for [Shaked](https://github.com/Shaked/gomobiledetect) and [serbanghita](https://github.com/serbanghita/Mobile-Detect).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhouseme%2Fmobiledetect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhouseme%2Fmobiledetect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhouseme%2Fmobiledetect/lists"}