{"id":23394827,"url":"https://github.com/dineshgowda24/browser","last_synced_at":"2025-04-11T12:54:00.191Z","repository":{"id":199921515,"uuid":"690226647","full_name":"dineshgowda24/browser","owner":"dineshgowda24","description":"Browser detection in Go (golang)","archived":false,"fork":false,"pushed_at":"2024-05-18T22:39:42.000Z","size":468,"stargazers_count":87,"open_issues_count":2,"forks_count":3,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-25T09:11:59.950Z","etag":null,"topics":["browser","go","golang","user-agent","user-agent-analysis","user-agent-parser"],"latest_commit_sha":null,"homepage":"https://browser.dineshgowda.com","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/dineshgowda24.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-09-11T19:29:02.000Z","updated_at":"2025-01-13T11:13:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"da08f95a-7bc7-4534-8dda-f12692739ae3","html_url":"https://github.com/dineshgowda24/browser","commit_stats":null,"previous_names":["dineshgowda24/browser"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dineshgowda24%2Fbrowser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dineshgowda24%2Fbrowser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dineshgowda24%2Fbrowser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dineshgowda24%2Fbrowser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dineshgowda24","download_url":"https://codeload.github.com/dineshgowda24/browser/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248403787,"owners_count":21097587,"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":["browser","go","golang","user-agent","user-agent-analysis","user-agent-parser"],"created_at":"2024-12-22T06:18:17.564Z","updated_at":"2025-04-11T12:54:00.162Z","avatar_url":"https://github.com/dineshgowda24.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# browser [![MIT](https://img.shields.io/github/license/dineshgowda24/browser)](https://github.com/dineshgowda24/browser/blob/main/LICENSE) [![Go Reference](https://pkg.go.dev/badge/github.com/dineshgowda24/browser.svg)](https://pkg.go.dev/github.com/dineshgowda24/browser) [![Go report card](https://goreportcard.com/badge/github.com/dineshgowda24/browser)](https://goreportcard.com/report/github.com/dineshgowda24/browser) [![Build Status](https://dl.circleci.com/status-badge/img/circleci/MQTLZJuBejHgr2yqrojz3u/5NTLeuQeViQw2JaPQf7gKa/tree/main.svg?style=shield\u0026circle-token=ab7a417fe410b8387c767f83568f7d2f2788ac4f)](https://dl.circleci.com/status-badge/redirect/circleci/MQTLZJuBejHgr2yqrojz3u/5NTLeuQeViQw2JaPQf7gKa/tree/main) [![Coverage](https://codecov.io/gh/dineshgowda24/browser/graph/badge.svg?token=XUA2VJW5FU)](https://codecov.io/gh/dineshgowda24/browser) [![X](https://img.shields.io/twitter/follow/_dineshgowda)](https://twitter.com/_dineshgowda)\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"logo.png\"\u003e\n\u003c/p\u003e\n\n## Why?\n\n\u003e *Why not?*\n\nYou need to detect the browser, device and platform from the user agent string in many use cases. I have personally come across the following use cases:\n\n1. You want to render different HTML for different browsers, devices or platforms.\n2. You want to render OG tags for scraping bots and social media sites.\n3. You want to log the browser, device or platform for your analytics.\n4. You want your backend to behave differently when a Google bot crawls your site for SEO.\n\nI wanted a relatively extensible package that I could use in all the above use cases. So, I decided to write this package.\n\n## Inspiration\n\nThe ruby gem [fnando/browser](https://github.com/fnando/browser) inspires this package. I have used the gem in some of my previous projects and liked it. All the credit goes to the author of the ruby gem, who has done a great job.\n\n## Documentation\n\nFor detailed documentation visit [browser.dineshgowda.com](https://browser.dineshgowda.com). It has adoption guides, usage, contributing guidelines and also the list of all the matchers and browsers supported.\n\n## Usage\n\n```go\ngo get github.com/dineshgowda24/browser\n```\n\n### Browser Detection\n\n```go\nb, err := browser.NewBrowser(\"Mozilla/5.0 (Linux; Android 10; SM-A205U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.210 Mobile Safari/537.36\")\n if err != nil {\n  // handle error\n }\n\n // browser level information\n fmt.Println(b.Name())           // Chrome\n fmt.Println(b.Version())        // 90.0.4430.210\n fmt.Println(b.ShortVersion())   // 90\n fmt.Println(b.IsBrowserKnown()) // true\n fmt.Println(b.IsChrome())       // true\n\n // device level information\n fmt.Println(b.Device().Name())      // Samsung SM-A205U\n fmt.Println(b.Device().IsTablet())  // false\n fmt.Println(b.Device().IsSamsung()) // true\n\n // platform level information\n fmt.Println(b.Platform().Name())         // Android\n fmt.Println(b.Platform().Version())      // 10\n fmt.Println(b.Platform().IsAndroidApp()) // false\n\n // bot level information\n fmt.Println(b.Bot().Name())  // \"\"\n fmt.Println(b.Bot().IsBot()) // false\n```\n\n### Bot Detection\n\n```go\nb, err := browser.NewBrowser(\"APIs-Google (https://developers.google.com/webmasters/APIs-Google.html)\")\nif err != nil {\n   // handle error\n}\n\n// browser level information\nfmt.Println(b.Name())           // Unknown Browser\nfmt.Println(b.Version())        // 0.0\nfmt.Println(b.ShortVersion())   // 0\nfmt.Println(b.IsBrowserKnown()) // false\nfmt.Println(b.IsUnknown())      // true\n\n// bot level information\nfmt.Println(b.Bot().Name())  // \"APIs-Google\"\nfmt.Println(b.Bot().IsBot()) // true\nfmt.Println(b.Bot().Why())   // *bots.Known\n```\n\n## Contributing\n\nIf you want to contribute to this project, please read the [CONTRIBUTING.md](CONTRIBUTING.md) file.\n\n## Issues\n\nIf you find any issues with this package, please raise an issue. I will fix it as soon as possible. Please read the `Contributing` section if you want to resolve the issue and contribute.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdineshgowda24%2Fbrowser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdineshgowda24%2Fbrowser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdineshgowda24%2Fbrowser/lists"}