diff --git a/README.md b/README.md index 2e39777..a0d769b 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,12 @@ -# Go/Golang package for parsing user agent strings [![GoDoc](https://godoc.org/github.com/mileusna/useragent?status.svg)](https://godoc.org/github.com/mileusna/useragent) +# Go/Golang package for parsing user agent strings [![GoDoc](https://godoc.org/github.com/andoma-go/useragent?status.svg)](https://godoc.org/github.com/andoma-go/useragent) Use `useragent.Parse(userAgent string)` function to parse browser's and bot's user agents strings and get: -+ User agent name and version (Chrome, Firefox, Googlebot, etc.) -+ Operating system name and version (Windows, Android, iOS etc.) -+ Device type (mobile, desktop, tablet, bot) -+ Device name if available (iPhone, iPad, Huawei VNS-L21) -+ URL provided by the bot (http://www.google.com/bot.html etc.) + +- User agent name and version (Chrome, Firefox, Googlebot, etc.) +- Operating system name and version (Windows, Android, iOS etc.) +- Device type (mobile, desktop, tablet, bot) +- Device name if available (iPhone, iPad, Huawei VNS-L21) +- URL provided by the bot (http://www.google.com/bot.html etc.) ## Status @@ -14,8 +15,9 @@ Stable. I use it on high traffic websites on every single request, as well on my I constantly improve user agents detection and performance. Fill free to report an issue for any User-Agent string not recognized or misinterpreted. ## Installation + ``` -go get github.com/mileusna/useragent +go get github.com/andoma-go/useragent ``` ## Example @@ -27,14 +29,14 @@ import ( "fmt" "strings" - "github.com/mileusna/useragent" + "github.com/andoma-go/useragent" ) func main() { userAgents := []string{ "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", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36", - "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", + "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", "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", "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", "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", @@ -82,7 +84,9 @@ Beside `UserAgent{}` struct and its properties returned by `useragent.Parse()`, // do something } ``` + can be also written on this way: + ```go ua := useragent.Parse(userAgentString) if ua.IsAndroid() && ua.IsChrome() { @@ -92,8 +96,5 @@ can be also written on this way: ## Notice -+ Opera and Opera Mini are two browsers, since they operate on very different ways. -+ If Googlebot (or any other bot) is detected and it is using its mobile crawler, both `bot` and `mobile` flags will be set to `true`. - - - +- Opera and Opera Mini are two browsers, since they operate on very different ways. +- If Googlebot (or any other bot) is detected and it is using its mobile crawler, both `bot` and `mobile` flags will be set to `true`. diff --git a/go.mod b/go.mod index ab4182e..6fa6abb 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ -module github.com/mileusna/useragent +module github.com/andoma-go/useragent go 1.14 diff --git a/ua_test.go b/ua_test.go index 293b5a4..04cefb7 100644 --- a/ua_test.go +++ b/ua_test.go @@ -5,7 +5,7 @@ import ( "strings" "testing" - ua "github.com/mileusna/useragent" + ua "github.com/andoma-go/useragent" ) var testTable = [][]string{