chore: change module name after fork
This commit is contained in:
@@ -1,11 +1,12 @@
|
|||||||
# Go/Golang package for parsing user agent strings [](https://godoc.org/github.com/mileusna/useragent)
|
# Go/Golang package for parsing user agent strings [](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:
|
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.)
|
- User agent name and version (Chrome, Firefox, Googlebot, etc.)
|
||||||
+ Device type (mobile, desktop, tablet, bot)
|
- Operating system name and version (Windows, Android, iOS etc.)
|
||||||
+ Device name if available (iPhone, iPad, Huawei VNS-L21)
|
- Device type (mobile, desktop, tablet, bot)
|
||||||
+ URL provided by the bot (http://www.google.com/bot.html etc.)
|
- Device name if available (iPhone, iPad, Huawei VNS-L21)
|
||||||
|
- URL provided by the bot (http://www.google.com/bot.html etc.)
|
||||||
|
|
||||||
## Status
|
## 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.
|
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>
|
## Installation <a id="installation"></a>
|
||||||
|
|
||||||
```
|
```
|
||||||
go get github.com/mileusna/useragent
|
go get github.com/andoma-go/useragent
|
||||||
```
|
```
|
||||||
|
|
||||||
## Example<a id="example"></a>
|
## Example<a id="example"></a>
|
||||||
@@ -27,14 +29,14 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/mileusna/useragent"
|
"github.com/andoma-go/useragent"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
userAgents := []string{
|
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 (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 (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 (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 (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",
|
"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
|
// do something
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
can be also written on this way:
|
can be also written on this way:
|
||||||
|
|
||||||
```go
|
```go
|
||||||
ua := useragent.Parse(userAgentString)
|
ua := useragent.Parse(userAgentString)
|
||||||
if ua.IsAndroid() && ua.IsChrome() {
|
if ua.IsAndroid() && ua.IsChrome() {
|
||||||
@@ -92,8 +96,5 @@ can be also written on this way:
|
|||||||
|
|
||||||
## Notice
|
## Notice
|
||||||
|
|
||||||
+ Opera and Opera Mini are two browsers, since they operate on very different ways.
|
- 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`.
|
- 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,3 +1,3 @@
|
|||||||
module github.com/mileusna/useragent
|
module github.com/andoma-go/useragent
|
||||||
|
|
||||||
go 1.14
|
go 1.14
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
ua "github.com/mileusna/useragent"
|
ua "github.com/andoma-go/useragent"
|
||||||
)
|
)
|
||||||
|
|
||||||
var testTable = [][]string{
|
var testTable = [][]string{
|
||||||
|
|||||||
Reference in New Issue
Block a user