forked from yoavfeld/udger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
61 lines (53 loc) · 1.4 KB
/
types.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
package udger
import (
"database/sql"
"regexp"
_ "github.com/mattn/go-sqlite3"
)
// Udger contains the data and exposes the Lookup(ua string) function
type Udger struct {
db *sql.DB
rexBrowsers []rexData
rexDevices []rexData
rexOS []rexData
browserTypes map[int]string
browserOS map[int]int
Browsers map[int]Browser
OS map[int]OS
Devices map[int]Device
Flags *Flags
}
// Info is the struct returned by the Lookup(ua string) function, contains everything about the UA
type Info struct {
Browser Browser `json:"browser"`
OS OS `json:"os"`
Device Device `json:"device"`
}
// Browser contains information about the browser type, engine and off course it's name
type Browser struct {
Name string `json:"name"`
Family string `json:"family"`
Version string `json:"version"`
Engine string `json:"engine"`
typ int
Type string `json:"type"`
Company string `json:"company"`
Icon string `json:"icon"`
}
type rexData struct {
ID int
Regex string
RegexCompiled *regexp.Regexp
}
// OS contains all the information about the operating system
type OS struct {
Name string `json:"name"`
Family string `json:"family"`
Icon string `json:"icon"`
Company string `json:"company"`
}
// Device contains all the information about the Device type
type Device struct {
Name string `json:"name"`
Icon string `json:"icon"`
}