-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcache.go
96 lines (86 loc) · 2.09 KB
/
cache.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
package devicedetector
import (
"embed"
"log"
)
type Cache struct {
Bot BotCache
Client ClientCache
Device DeviceCache
Hint HintCache
OS OSCache
}
//go:embed regexes/bots.yml
//go:embed regexes/client/browser_engine.yml
//go:embed regexes/client/browsers.yml
//go:embed regexes/client/feed_readers.yml
//go:embed regexes/client/hints/apps.yml
//go:embed regexes/client/hints/browsers.yml
//go:embed regexes/client/libraries.yml
//go:embed regexes/client/mediaplayers.yml
//go:embed regexes/client/mobile_apps.yml
//go:embed regexes/client/pim.yml
//go:embed regexes/device/cameras.yml
//go:embed regexes/device/car_browsers.yml
//go:embed regexes/device/consoles.yml
//go:embed regexes/device/mobiles.yml
//go:embed regexes/device/notebooks.yml
//go:embed regexes/device/portable_media_player.yml
//go:embed regexes/device/shell_tv.yml
//go:embed regexes/device/televisions.yml
//go:embed regexes/oss.yml
//go:embed regexes/vendorfragments.yml
var embeddedData embed.FS
// List of all files in cache
var cacheFiles = []string{
"bots.yml",
"client/browser_engine.yml",
"client/browsers.yml",
"client/feed_readers.yml",
"client/hints/apps.yml",
"client/hints/browsers.yml",
"client/libraries.yml",
"client/mediaplayers.yml",
"client/mobile_apps.ym.",
"client/pim.yml",
"device/cameras.yml",
"device/car_browsers.yml",
"device/consoles.yml",
"device/mobiles.yml",
"device/notebooks.yml",
"device/portable_media_player.yml",
"device/shell_tv.yml",
"device/televisions.yml",
"oss.yml",
"vendorfragments.yml",
}
func NewEmbeddedCache() (*Cache, error) {
botCache, err := NewEmbeddedBotCache()
if err != nil {
return nil, err
}
clientCache, err := NewEmbeddedHintCache()
if err != nil {
return nil, err
}
deviceCache, err := NewEmbeddedDeviceCache()
if err != nil {
return nil, err
}
osCache, err := NewEmbeddedOSCache()
if err != nil {
return nil, err
}
client, err := NewEmbeddedClientCache()
if err != nil {
log.Println(err)
return nil, err
}
return &Cache{
Bot: botCache,
Client: client,
Device: deviceCache,
Hint: clientCache,
OS: osCache,
}, nil
}