2
0

chore: change module name after fork

This commit is contained in:
2023-06-01 23:40:59 +03:00
parent e3016d532e
commit 8e074e2cca
3 changed files with 17 additions and 16 deletions
+15 -14
View File
@@ -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 <a id="installation"></a>
```
go get github.com/mileusna/useragent
go get github.com/andoma-go/useragent
```
## Example<a id="example"></a>
@@ -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`.
+1 -1
View File
@@ -1,3 +1,3 @@
module github.com/mileusna/useragent
module github.com/andoma-go/useragent
go 1.14
+1 -1
View File
@@ -5,7 +5,7 @@ import (
"strings"
"testing"
ua "github.com/mileusna/useragent"
ua "github.com/andoma-go/useragent"
)
var testTable = [][]string{