-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerator.go
More file actions
57 lines (52 loc) · 1.19 KB
/
generator.go
File metadata and controls
57 lines (52 loc) · 1.19 KB
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
package main
import (
"compress/gzip"
"os"
"github.com/Hubmakerlabs/shonen-data/game"
"github.com/Hubmakerlabs/shonen-data/locale"
)
const (
localeJson = "countriestimezoneslanguages.json"
localeJsonGz = localeJson + ".gz"
gamesJsonFile = "games.json"
gamesJsonFileGz = gamesJsonFile + ".gz"
timezonesJson = "timezones.json"
)
func main() {
var err error
_, _, err = locale.GetTimezones(timezonesJson)
nations := locale.GetNations(localeJson)
var fh *os.File
fh, err = os.OpenFile(localeJsonGz, os.O_CREATE|os.O_TRUNC|os.O_RDWR, 0666)
if err != nil {
panic(err)
}
var w *gzip.Writer
w, err = gzip.NewWriterLevel(fh, gzip.BestCompression)
_, err = w.Write([]byte(nations))
if err != nil {
panic(err)
}
if err = w.Flush(); err != nil {
panic(err)
}
if err = w.Close(); err != nil {
panic(err)
}
games := game.GetMpGames(gamesJsonFile)
fh, err = os.OpenFile(gamesJsonFileGz, os.O_CREATE|os.O_TRUNC|os.O_RDWR, 0666)
if err != nil {
panic(err)
}
w, err = gzip.NewWriterLevel(fh, gzip.BestCompression)
_, err = w.Write([]byte(games))
if err != nil {
panic(err)
}
if err = w.Flush(); err != nil {
panic(err)
}
if err = w.Close(); err != nil {
panic(err)
}
}