-
Notifications
You must be signed in to change notification settings - Fork 66
/
is.go
102 lines (82 loc) · 2.71 KB
/
is.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package useragent
// IsWindows shorthand function to check if OS == Windows
func (ua UserAgent) IsWindows() bool {
return ua.OS == Windows
}
// IsAndroid shorthand function to check if OS == Android
func (ua UserAgent) IsAndroid() bool {
return ua.OS == Android
}
// IsMacOS shorthand function to check if OS == MacOS
func (ua UserAgent) IsMacOS() bool {
return ua.OS == MacOS
}
// IsIOS shorthand function to check if OS == IOS
func (ua UserAgent) IsIOS() bool {
return ua.OS == IOS
}
// IsLinux shorthand function to check if OS == Linux
func (ua UserAgent) IsLinux() bool {
return ua.OS == Linux
}
// IsChromeOS shorthand function to check if OS == CrOS
func (ua UserAgent) IsChromeOS() bool {
return ua.OS == ChromeOS || ua.OS == "CrOS"
}
// IsBlackberryOS shorthand function to check if OS == BlackBerry
func (ua UserAgent) IsBlackberryOS() bool {
return ua.OS == BlackBerry
}
// IsOpera shorthand function to check if Name == Opera
func (ua UserAgent) IsOpera() bool {
return ua.Name == Opera
}
// IsOperaMini shorthand function to check if Name == Opera Mini
func (ua UserAgent) IsOperaMini() bool {
return ua.Name == OperaMini
}
// IsChrome shorthand function to check if Name == Chrome
func (ua UserAgent) IsChrome() bool {
return ua.Name == Chrome
}
// IsFirefox shorthand function to check if Name == Firefox
func (ua UserAgent) IsFirefox() bool {
return ua.Name == Firefox
}
// IsInternetExplorer shorthand function to check if Name == Internet Explorer
func (ua UserAgent) IsInternetExplorer() bool {
return ua.Name == InternetExplorer
}
// IsSafari shorthand function to check if Name == Safari
func (ua UserAgent) IsSafari() bool {
return ua.Name == Safari
}
// IsEdge shorthand function to check if Name == Edge
func (ua UserAgent) IsEdge() bool {
return ua.Name == Edge
}
// IsBlackBerry shorthand function to check if Name == BlackBerry
func (ua UserAgent) IsBlackBerry() bool {
return ua.Name == BlackBerry
}
// IsGooglebot shorthand function to check if Name == Googlebot
func (ua UserAgent) IsGooglebot() bool {
return ua.Name == Googlebot
}
// IsTwitterbot shorthand function to check if Name == Twitterbot
func (ua UserAgent) IsTwitterbot() bool {
return ua.Name == Twitterbot
}
// IsFacebookbot shorthand function to check if Name == FacebookExternalHit
func (ua UserAgent) IsFacebookbot() bool {
return ua.Name == FacebookExternalHit
}
// IsYandexbot shorthand function to check if Name == YandexBot
func (ua UserAgent) IsYandexbot() bool {
return ua.Name == YandexBot
}
// IsUnknown returns true if the package can't determine the user agent reliably.
// Fields like Name, OS, etc. might still have values.
func (ua UserAgent) IsUnknown() bool {
return !ua.Mobile && !ua.Tablet && !ua.Desktop && !ua.Bot
}